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

Free Support Forum - aspose.com

How to create document node from existing OOXML

I want to extract XML of a node and want to construct node from that XML at another document. Like

And want to get XML of a Paragraph node.

<w:p w:rsidR="00C07F31" w:rsidRDefault="003F6D7A">
<w:r w:rsidRPr="003F6D7A">
<w:b />
<w:t xml:space="preserve">World.</w:t>

then want to create Paragraph node from that XML at another document.
N.B. Paragraph may contain images or shapes and equations. So I have to save and reconstruct those also.
Is it possible using Aspose.Word library?


Thanks for your inquiry. You can easily get a node from existing document and create new document from it using Aspose.Words. Please check following sample code snippet, Please also check following related documentation links for more details.

  • Aspose.Words Document Object Model(DOM)

  • ImportNode method

  • How to extract selected contents between nodes in Document

    Document srcDoc = new Document(@“src.docx”);
    //Open or create destination document
    Document dstDoc = new Document();
    //Get node form src document
    //Let’s get first table for example
    Table srcTable = srcDoc.FirstSection.Body.Tables[0];
    //Import this node
    Node dstNode = dstDoc.ImportNode(srcTable, true, ImportFormatMode.KeepSourceFormatting);
    //Insert this node into the destination document
    //You also can use InsertAfter and InsertBefore methods
    OoxmlSaveOptions options = new OoxmlSaveOptions(SaveFormat.Docx);
    //Save dst document

Best Regards,

Thank you Tailal for your reply. But if Aspose included a property like var xmlTxt = node.Xml; from where we will be able to get the underlying XML and if we want to create that node from that XML we will set the Xml text into node.Xml = xmlTxt; then it will be very easy to take document node Xml and save that into DB and later reconstruct that node into another document construction time.

At the example, you are working using a whole word document. But I want to extract only paragraph node XML text and from that paragraph XML again want to create Paragraph node object.


Thanks for your feedback. Currently, Aspose.Words does not support to get and set Node XML text, so we have logged a new feature request WORDSNET-15623 in our issue tracking system. We will keep you updated about its resolution progress within this forum thread.

Please note to extract your required paragraph node you need to load whole document in API DOM for further manipulation.

Best Regards,


Thanks for your patience. We have investigated your requirement and found there is no simple way to achieve this. Because styles, themes, shapes are stored inside the document not inside the node. Also it involves inheritance from parents. So, the only way we can propose is to clone and clear the original document and use it as container for all the nodes you would like to store, and then just save this document to the database.

Best Regards,