turn off unescaping in SAXParser
I am using SAXParser in Java.
Is there a way to turn off unescaping while parsing xml using SAXParser?
For example I have the following xml:
<tag>
„title”
</tag>
I would like to obtain by characters(char[] ch, int start, int length) message „title”
but the handler unescapes content o开发者_如何学Pythonf the xml and gives:
„title”
I tried with specifying custom EntityResolver, but it seems that resolveEntity() method never gets called.
The SAXParser is doing what it is supposed to do but if you want to preserve a text node as-is you need to wrap it in a CDATA section. You can either do this as a preprocess step or perhaps there is a way to do the wrapping while parsing (but I don't know how).
精彩评论