Free Support Forum -

Insert user-defined XML tags in DOC


I wonder if I can insert user-defined XML tags into the doc generated by ASPOSE.WORD,

without destroying the word formation such as font, color etc. Shown as attached JPG

Lin Jiale


Thanks for your request. Yes, you can insert custom XML into your document programmatically using Aspose.Words. Please see CustomXmlMarkup class for more information:

Here is a simple code example that demonstrates how to create custom xml markup:

// Create document.

Document doc = new Document();

// Create a custom XML markup.

CustomXmlMarkup markup = new CustomXmlMarkup(doc, MarkupLevel.Inline);

markup.Element = "test";

// Insert some content between tags.

Run text = new Run(doc, "This is text inside custom xml");


// Insert custom xml into the document.


// Save output


Hope this helps.

Best regards,