Hi, I am using JAXP parsing some xml files,
however I found all "
"s in xml source are converted as "\n" in the parsed java String. Is there any switches that forbid the parser to do this automatic transforming?
My code is like below:
Document doc = null;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
doc = builder.parse(input);
This topic has been locked.
2 replies Latest Post - 2007-05-01T12:56:12Z by SystemAdmin
Pinned topic Things about escapes
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2007-05-01T12:56:12Z at 2007-05-01T12:56:12Z by SystemAdmin
Re: Things about escapes2007-04-30T13:58:15Z in response to SystemAdminYou're describing the usual whitespace normalization process on XML parse, so there is probably no way to turn it off. If you absolutely must maintain "
" characters one workaround is to convert them to another character before parse, perhaps something in the Unicode private use area, just to be safe. You can then convert then back to "
" whenever you need the actual character data. Yes this is a hack, but there's not much you can do when you're fighting the purposeful limitations in XML 1.0.