I need to save an xml that I'm doing.
The content of one node is a CDATA with an xml embed. It seems to be working, but when I save the file the '<' characters are replaced by < and so on and I don't know how to solve it.
I have seen that I can use a SAX-writer handler that has the write-cdata function, but when I show the node content it's well formed, so the problem seems to be in the save file process.
Thanks in advance.
This is the code used to write the node.
cFilePath = 'test.xml'. DEFINE VARIABLE cXmlContent AS MEMPTR NO-UNDO. COPY-LOB FROM FILE cFilePath TO cXmlContent . hDoc:CREATE-NODE(hNode, 'test', 'ELEMENT'). hParent:APPEND-CHILD(hNode). hDoc:CREATE-NODE(hChildNodeText, '', 'TEXT'). hNode:APPEND-CHILD (hChildNodeText). hChildNodeText:NODE-VALUE = '<![CDATA[' + GET-STRING(cXmlContent , 1) + ']]>'.
You probably need to change the 'TEXT' subtype of the node to 'CDATA-SECTION'.
Checked in the copy-lob line, but it's not working.
You probably need to change the 'TEXT' subtype of the node to 'CDATA-SECTION'.
Thanks Richard!! Didn't know about the subtype CDATA-SECTION.
I just learned after reading your question :)