Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

CRLF characters in CDATA section

843834Oct 3 2001 — edited Sep 2 2009
I 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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 30 2009
Added on Oct 3 2001
5 comments
1,368 views