开发者

Java Sax Parser does not recognize < and > [duplicate]

开发者 https://www.devze.com 2023-04-02 09:33 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: SAXParser '&&开发者_StackOverflow中文版#39; concatenation problem
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

SAXParser '&&开发者_StackOverflow中文版#39; concatenation problem

I wrote a small Sax Parser in Java. In my file, I have some &lt; and &gt; escaped chars. However, instead of giving me < and >, the parser just stops for the chars when these sequences are met.

I mean, if I parse: "aaa &lt; bbb", I'll get "aaa".

Thanks in advance for your help :).


Firstly, I don't think you wrote a SAX parser. I think you wrote a SAX ContentHandler. Saying you wrote a parser is like saying you're a baker because you bought a loaf of bread this morning.

Secondly: read the spec. In SAX, the parser is allowed to supply the content of text nodes in as many calls to characters() as it likes. It's the job of the ContentHandler to assemble them. Many parsers choose to break the text at natural boundaries like the start and end of entity and character references, because that reduces the need for copying of character arrays.

0

精彩评论

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