开发者

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>
    &#8222;title&#8221;
</tag>

I would like to obtain by characters(char[] ch, int start, int length) message &#8222;title&#8221;

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜