Insert user-defined XML tags in DOC

Hi,

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

Hi
Thanks for your request. Yes, you can insert custom XML into your document programmatically using Aspose.Words. Please see CustomXmlMarkup class for more information:
https://reference.aspose.com/words/net/aspose.words.markup/
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");
markup.AppendChild(text);
// Insert custom xml into the document.
doc.FirstSection.Body.FirstParagraph.AppendChild(markup);
// Save output
doc.Save(@"Test001\out.doc");

Hope this helps.
Best regards,