Welcome to OpenXML Developer Sign in | Join | Help

insert html in word :replacing content of the xml tag with html.

Last post 10-07-2008, 4:56 AM by beast. 1 replies.
Sort Posts: Previous Next
  •  08-25-2008, 9:10 AM 3603

    insert html in word :replacing content of the xml tag with html.

    Hi

    I was able to get a solution from sheela and replace the xml tag with html using the altchunk.

    Here is the problem i face.

    I have 3 tags. when i replace all the other tags get replaced with the first tag.

    here is the piece of code.

    any ideal why it is happening.

    thx

    egards

    mahesh

    NameTable nt = new NameTable();
                XmlNamespaceManager nsManager = new XmlNamespaceManager(nt);
                nsManager.AddNamespace("w", wordmlNamespace);
                XmlElement node = xdoc.CreateElement("w:altChunk", wordmlNamespace);
                XmlAttribute attr = node.Attributes.Append(xdoc.CreateAttribute("r:id", relationshipNamespace));
                attr.Value = relid;

                XmlNode targetNode = xdoc.SelectSingleNode("//w:customXml[@w:uri='http://tempuri.org/XMLSchema.xsd' and @w:element='"+tag+"']", nsManager);

                // if that tag is present then replace it
               
                if (targetNode != null ) {
                     targetNode.ReplaceChild(node, targetNode.LastChild);
                }
               
                // save the word document
                xdoc.Save(mainpart);
                dd.Save(altchunk.GetStream());            
                wordDoc.Close();

     

  •  10-07-2008, 4:56 AM 3764 in reply to 3603

    Re: insert html in word :replacing content of the xml tag with html.

    Hi

     

    I think you can try using third-party component for inserting HTML into the Word document. For example Aspose.Words.

    http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/introducing-aspose-words.html

     

    Here is guide how you can achieve this.

    http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/inserting-html.html

     

    WBR,

    Alex

View as RSS news feed in XML