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);
Re: Things about escapes2007-04-30T13:58:15ZThis is the accepted answer. This is the accepted answer.You'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.