Xml to document

Hi,

I need to insert a xml(Word 2007 XML) to the aspose document. And one Aspose staff said that:
"
Hello

Thanks for your request. If you XML is MS Word document (I mean Word 2003 or Word 2007 XML) then you can try loading this XML into Aspose.Words Document object and process with Aspose.Words. Using Aspose.Words you can create, modify, edit, and merge any of MS Words documents. Please see the following link to learn how to insert a document into another document:
https://docs.aspose.com/words/net/insert-and-append-documents/

"
But HOW I convert my xml to Aspose Document?

Thanks for any help,
Vuong Le

Hi

Thanks for your request. Please see the following link to learn how to open document using Aspose.Words:
https://docs.aspose.com/words/net/create-or-load-a-document/

If your XML document is in file, you should simply pass file name into the Document constructor, if it is in the stream, pass this stream into the constructor.

Please let us know if you need more assistance, we are always glad to help you.

Best regards,

Hi Alexey,

Thanks for your quick reply.
I have the following word xml:

<?xml version="1.0" standalone="yes" ?>

<?mso-application progid="Word.Document"?>
<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
    <pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512">
    <pkg:xmlData>
    <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    .
    .
    .
    .
<w:sig w:usb0="A00002EF" w:usb1="4000004B" w:usb2="00000000" w:usb3="00000000" w:csb0="0000009F" w:csb1="00000000" />
</w:font>
</w:fonts>
</Relationships></pkg:xmlData>
</pkg:part>
</pkg:package>

In this xml, there are an image and a text. I need to insert this xml to another aspose document. Here is my code:

Document tempDoc = ConvertXmlToNode(additionalText);
Node currentNode = _builder.CurrentNode;
CompositeNode parentNode = currentNode == null ? null : currentNode.ParentNode;
// This object will be translating styles and lists during the import.
NodeImporter importer = new NodeImporter(_document, tempDoc, ImportFormatMode.KeepSourceFormatting);
parentNode.InsertAfter(currentNode, tempDoc);

I got an exception said that: document(tempDoc) is not a child of “parentNode”

Here is one guide from Aspose:
https://forum.aspose.com/t/58679
But, When I followed the guide. I also got another exception.

So, what is the correct solution for my problem?

Thanks and regards,

Vuong Le

Hi

Thanks for your request. Why do not you use the approach suggested earlier, i.e. using InsertDocument method? In the document, there is a certain nodes hierarchy, so you cannot insert a whole document after a paragraph as you do in your code. Please see the following link to learn more about document nodes hierarchy:
https://docs.aspose.com/words/net/aspose-words-document-object-model/

So, please try using InsertDocument method as described here:
https://docs.aspose.com/words/net/insert-and-append-documents/

Best regards,