Reading and Modifying XML In Word 2003 Documents


Is Aspose going to eventually support reading and manipulation of the XML in the Word 2003 Documents?

Our shop has found that by using the Word XML that we can provide custom logic to show and hide various regions of text from our templates, by wrapping the regions in XML elements and then removing the text in the element during the merge. Also, the XML feature is nice because you can clearly see the XML markup in Word 2003 and makes manipulating the templates easy for the designer.

Does Apose.Word support a good way to mark text and associate logic to it?


We surely plan to support WordXML and it is on our top priority list. You can expect to see some results in 1-2 months.

I’m not sure what do you want to mark text and associate logic to it?

You can create merge fields and run MailMerge.Execute that will either fill the fields from your data source automatically or call MergeField event handler you provided. In this handler you can execute some custom logic and decide what you want to insert into the document at that field’s location.

Also, you can just open the document and use bookmarks to navigate into various places in the document and do something with the document. There are other ways to navigate to places in the document using DocumentBuilder MoveToXXX methods.


Thanks for your reply.

To answer your question about why we would want to do this is for several reasons:

1. It adds the flexibility to include paragraphs or even entire blocks of text/formatting/images (ie. content) then have it be removed simply by removing the range within the XML tag in Word OR leaving the content in place. This provides the template implementer more precision in their ability to create robust templates that could include one or more sentences or content embedded within other content.

2. The XML tags are clear markers in the document as to where they start and begin even provide a way of nesting these begin and end markers whereas all the other features in Word are obscure. For example, bookmarks are invisible and can be easly deleted by accident and are hard to ensure that the correct content is selected.

I hope this answers your question. I am really looking forward to your support of XML in the future with this feature I will be able to totally get away from using office and use the Aspose components exclusively.

Great work on the Aspose.Word API and component I am very impressed and look forward to its future development! Also, I wanted to say that you have fabulous response to these posts and work to solve the problems actively! Keep up the good work it is much appreciated and a HUGE factor in deciding to purchase the Aspose components.


Thanks for the support.

Although we will import and export Word XML files in the near future we are not yet planning to expose XML nodes through the Aspose.Word API.

I’ve read someone’s blog that when MS Word classic object model with Ranges was mixed with access to XML nodes this resulted in some difficulties. Don’t remember exactly, but I think it basically does not work smoothly.

So I’m thinking it would probably be easier to manipulate XML documents using .NET XML classes just before loading it into Aspose.Word, not while in Aspose.Word.


Ah, good solution. So I guess that leaves me wondering when your expected delivery will be for reading the Wpml XML documents?

Do you have some place where you post your expected enhancement releases? (i.e. in 2.1 we’ll support reading Wpml and in 2.2 we’ll support comments)


I am very interested when this feature will be available as well.


I just tried the latest version (demo) and when I try to
open a Word 2003 xml file it failed with unsupported extension
exception. Is that feature have been added ?


Working with Word xml documents is not yet supported by Aspose.Words.