I have a libxmljs document in which I would like to append html fragment. For example:
var value = '<div xmlns="http://www.w3.org/1999/xhtml"><p>Soemthing</p></div>';
document.root().node('field', value);
But I would like to preserve html structure. Because after generating xml, inside field I get
<field><div xmlns="http://www.w3.org/1999/xhtml"><p>Something</p></div></field>
while I would like to achieve
<field><div xmlns="http://www.w3.org/1999/xhtml"><p>Something</p></div></field>
I know I can parse htmlFragment but I can't add it afterwards to document. So how to add html fragment? And preserve tags (if they are present)?
Thank you!
I used https://www.npmjs.com/package/xmlbuilder which has raw() method and can be used to insert html as well.