I am trying to add a xhtml content into SdtContent of a SdtRun element using XHTMLImporterImpl.
String xhtmlContent = "<html><body><a href="https://www.w3schools.com">20</a></body></html>"
XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(wordMLPackage);
List<Object> htmlPart = XHTMLImporter.convert( xhtmlContent, null);
if (htmlPart != null && !htmlPart.isEmpty()) {
sdtObject.getSdtContent().getContent().clear();
sdtObject.getSdtContent().getContent().addAll(htmlPart);
}
The <w:hyperlink> is wrapped under P element which is causing the issue I guess and the document generated is corrupted.
My xhtml content can also be a big html content as well with links, h1, p.
OpenXML structure

Need help on this, Please @plutext can you help on this issue