Doc / Docx File to XML Conversion

Dear Team,
I have some issue in doc/ docx file to xml file conversion, i tried various code but i’m not getting expected output

Document doc = new Document(MyDir + “in.docx”);
doc.Save(MyDir + “Out.xml”, SaveFormat.FLAT_OPC);

Document doc = new Document(MyDir + “in.docx”);
doc.Save(MyDir + “Out.xml”, SaveFormat.WORD_ML);

Input File - Actual Result - Expected result
Input & Output File.zip (6.4 MB)

@rjnick

Unfortunately, we cannot open the expected output in MS Word 2016. Could you please share some detail about your requirement and problem in Actualoutput.xml? We will then provide you more information about your query.

Dear @tahir.manzoor and Team,

Expected output is XML File so you cannot open in Ms Word 2016,
Kindly open the file in notepad or any other code editor.
Source,Input & output Files
Input & Output File.zip (6.4 MB)
Thank you in Advance.

@rjnick

Aspose.Words does not export the document to XML as you shared in the ZIP file. You need to iterate over document’s nodes, export the node to text using Node.ToString method, and write your own XML tags.

We suggest you please read about Aspose.Words’ DOM from here:
Aspose.Words Document Object Model