CRLF characters in CDATA section
843834Oct 3 2001 — edited Sep 2 2009I am trying to store a string in a CDATA section of an XML file. Many of my strings have CRLF characters (i.e. ASCII 13 + ASCII 10) and these are causing problems.
I create a DOM, then write the DOM out to a file - it looks like a reasonable XML file (with line breaks in the CDATA section where I expect them to be), though examining the actual bytes in the XML file shows that it contains 13,13,10 instead of 13,10.
When I parse the file to read it back into a DOM, then extract the String from the CDATA section, the 13,10 from the original string has been replaced by 10,10, so trying to display it shows a series of non-printing characters.
I have tried this with both JAXP and oracle.xml.parser.v2 and both approaches give very similar behaviour. I write the file out as UTF-8.
Does anyone have any suggestions about what might be going wrong?