DOMDocument - createTextNode, encoding problem

I have a problem with the createTextNode method: special characters like '>', '<':

Dim xmlDoc As DOMDocument Dim codeXML as String Dim n As IXMLDOMNode codeXML = '<data>value</data>' Set n = xmlDoc.createTextNode(codeXML) 

I need the result:

 <main><data>value</data></main> 

but i get

 <main>&lt;data&gt;value&lt;/data&gt;</main> 

How can I solve this problem?

Thank you very much.

0
source share
1 answer

One way is to create a second document that will serve as an XML parser for these XML literals. You can use LoadXML to pass a string and get validated XML objects. You can then import the node into the source / main DOM document you are building.

0
source

Source: https://habr.com/ru/post/979273/


All Articles