RichText StructuredDocumentTag cannot map to xml?

when i try to map a RichText StructuredDocumentTag to xml, i got an exception: Cannot map a rich-text structured document tag to XML data, but i can do this in ms word.

@qingyuan.ni,

Thanks for your inquiry. Please check the following code example for your kind reference. Hope this helps you.

If you still face problem, please share your input Word document and code example to reproduce your issue at our end. We will investigate the issue on our side and provide you more information.

Document doc = new Document();
CustomXmlPart xmlPart = doc.CustomXmlParts.Add(Guid.NewGuid().ToString("B"), "<root><text>Hello, World!</text></root>");

StructuredDocumentTag sdt = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Block);
doc.FirstSection.Body.AppendChild(sdt);

sdt.XmlMapping.SetMapping(xmlPart, "/root[1]/text[1]", "");

doc.Save(MyDir + "output.docx");

@tahir.manzoor

if change SdtType.PlainText to SdtType.RichText, there will be an exception when calling SetMapping, but in ms word, i can map it to a RichText StructuredDocumentTag

@qingyuan.ni,

Thanks for your inquiry. Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this.

@tahir.manzoor

I use a file as template, the template content need create by Aspose.Word, the input.docx is a sample created by MS Word. in the template, there are two sample, either one is acceptable. because the template file may be manaully modified, for example, the postion or text styles etc, so i think use custom xml file to identify the StructuredDocumentTag is a good idea.
input.zip (19.7 KB)

the output.docx is the final result
output.zip (26.6 KB)

I noticed that the RichText StructuredDocumentTag contains the hyperlink generated complex code in custom xml file, I don’t think it’s a good idea to make document content generating to the custom xml file, but I have no other way to generate a dynamic link to a static field.

@qingyuan.ni,

Thanks for sharing the detail. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-15954. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@qingyuan.ni,
The issues you have found earlier (filed as WORDSNET-15954) have been fixed in this Aspose.Words for .NET 17.12 update and this Aspose.Words for Java 17.12 update.
Please also check the following articles: