Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 874431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:06:10+00:00 2026-05-15T11:06:10+00:00

While debugging, the newly created element has its Prefix as w: , but the

  • 0

While debugging, the newly created element has its Prefix as w: , but the Xmldoc at the end loses it.

The resultant InnerXML for the Element below is:
<altChunk id="FF_HTML" xmlns="http://schemas.openxmlformats.org/wordprocessingml/2006/main" />

Expected Result is <w:altChunk r:id="FF_HTML"/>

private static XmlDocument prepareHTMLChunks(PackagePart partDocumentXML)
{
    XmlDocument doc = new XmlDocument();
    Stream xmlStream = partDocumentXML.GetStream();
    doc.Load(xmlStream);

    NameTable nt = new NameTable();
    nsManager = new XmlNamespaceManager(nt);            
    nsManager.AddNamespace("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");

    XmlNodeList nodeList = doc.SelectNodes("//w:bookmarkStart", nsManager);
    foreach (XmlNode node in nodeList)
    {
        foreach (XmlAttribute attr in node.Attributes)
        {
            if (attr.Value.EndsWith("HTML"))
            {
                //XmlElement el = doc.CreateElement("w","w:altChunk",string.Empty);
                XmlElement el = doc.CreateElement("altChunk",nsManager.LookupNamespace("w"));


                XmlAttribute altChunkAttr = doc.CreateAttribute("r","id",string.Empty);
                altChunkAttr.Prefix = "r";
                altChunkAttr.Value = attr.Value;
                el.SetAttributeNode(altChunkAttr); 

                XmlNode nodeToReplace = node.ParentNode;                        

                XmlNode bodyNode = doc.SelectSingleNode("//w:body", nsManager);
                bodyNode.ReplaceChild(el, nodeToReplace);                          
            }                    
        }
    }            
    return doc;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:06:10+00:00Added an answer on May 15, 2026 at 11:06 am

    Ok, I fixed it :

            private static XmlDocument prepareHTMLChunks(PackagePart partDocumentXML)
        {
    
            XmlDocument _document = new XmlDocument();
            Stream xmlStream = partDocumentXML.GetStream();
            _document.Load(xmlStream);
    
            XmlNamespaceManager _ns = new XmlNamespaceManager(_document.NameTable);
            _ns.AddNamespace("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
    
            XmlNode _body = _document.SelectSingleNode("//w:body", _ns);
    
            foreach (XmlNode _node in _document.SelectNodes("//w:bookmarkStart", _ns))
            {
                foreach (XmlAttribute _attribute in _node.Attributes)
                {
                    if (_attribute.Value.EndsWith("HTML"))
                    {
                        XmlElement _element = _document.CreateElement("w", "altChunk", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
                        XmlAttribute _newAttr = _document.CreateAttribute("r", "id", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");                        
                        _newAttr.Value = _attribute.Value;
                        _element.Attributes.Append(_newAttr);
                        _body.AppendChild(_element);                        
                    }           
                }
            }            
            return _document;       
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While debugging the code below, BroadcastReceiverCustom is being called but PhoneStateListenerCustom is not. For
While debugging ASP.NET MVC source i found MVC-ControllerTypeCache.xml file is used. But i am
I purchased MonoTouch Professional but while debugging with the iPhone it gives an error:
While debugging an application i am getting the following error. The CLR has been
While debugging some code I got something like below: #include<stdio.h> int main() { FILE
While debugging a variable in Eclipse that takes true but the same takes false
While debugging and keep pressing F5, if the source code does not exist, eclipse
While debugging crash in a multithreaded application I finally located the problem in this
While debugging an issue with our system, I have discovered a thread contention that
While debugging a .NET Framework 3.5, WinForms application I spotted some Worker Threads without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.