Problem with html characters saving html

Posted by untipet on 05-Mar-2018 07:22

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 &lt; 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) + ']]>'.

Posted by Richard.Kelters on 05-Mar-2018 08:22

You probably need to change the 'TEXT' subtype of the node to 'CDATA-SECTION'.

All Replies

Posted by goo on 05-Mar-2018 07:50

What about using no-convert?
 

Posted by untipet on 05-Mar-2018 08:00

Checked in the copy-lob line, but it's not working.

Posted by Richard.Kelters on 05-Mar-2018 08:22

You probably need to change the 'TEXT' subtype of the node to 'CDATA-SECTION'.

Posted by untipet on 05-Mar-2018 08:39

Thanks Richard!! Didn't know about the subtype CDATA-SECTION.

Posted by Richard.Kelters on 05-Mar-2018 08:56

I just learned after reading your question :)

This thread is closed