We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Range.InsertXML and Tables

I’ve got an application that uses Range.InsertXML to insert a table (with styling) in the old word markup format. I’ve looked for a means to replicate this behavior with aspose and only come across this post: https://forum.aspose.com/t/58679

It mentions loading the XML into a new document, and I’m not sure how to do that. Do I read the incoming XML string into a stream and use the stream overload of the document constructor? From there I guess I would query for table nodes in the resulting document and insert what I find using a document builder, but this feels a bit kludgy to me.

Is there an example of using the technique described in the linked post that could help shed some light on this?



Ok I’m not having any luck loading the XML into a document. I did find the “CustomXMLParts” collection off of the document, and I’m wondering if maybe I could use this?

Assuming this will work, adding a new CustomXmlPart to the collection seems easy enough. Once I’ve added it how can I get it to show in place of the book mark in question?



Hi Alex,

Thanks for your inquiry and sorry for the delayed response.

First of all, please note that Aspose.Words is quite different from the Microsoft Word’s Object Model in that it represents the document as a tree of objects more like an XML DOM tree. If you worked with any XML DOM library you will find it is easy to understand and work with Aspose.Words. When you load a Word document into Aspose.Words, it builds its DOM and all document elements and formatting are simply loaded into memory. Please read the following articles for more information on DOM:

Secondly, Aspose.Words provides exhaustive support for different XML-based formats for word processing documents e.g. OOXML, Flat OPC and also Word 2003 XML. You can load these formats directly by using Aspose.Words’ Document constructor. Once your XML document is loaded into Aspose.Words’ DOM, you can use DocumentExplorer to view the tree hierarchy:

Aspose.Words allows you to easily extract content from any word document type. For some examples please see the documentation here on extracting text and here on extracting content based on style. There are many other methods to to extract content, i.e you can extract content from tables, bookmarks and other nodes as well. Also, I would suggest you please read the following article on How to work with Tables in Aspose.Words:

Regarding CustomXmlPart class, you can learn more about it in our documentation. Please see the following API page:

Please let us know if you need more information; we are always glad to help you.

Best Regards,