SAX parser: Ignoring special characters

前端 未结 4 704
说谎
说谎 2020-12-07 01:41

I\'m using Xerces to parse my XML document. The issue is that XML escaped characters like   appear in characters() method as non-escap

4条回答
  •  悲哀的现实
    2020-12-07 02:07

    If you supply a LexicalHandler as a callback to the SAX parser, it will inform you of the start and end of every entity reference using startEntity() and endEntity() callbacks.

    (Note that the JavaDoc at http://download.oracle.com/javase/1.5.0/docs/api/org/xml/sax/ext/LexicalHandler.html talks of "entities" when the correct term is "entity references").

    Note also that there is no way to get a SAX parser to tell you about numeric character references such as . Applications are supposed to treat these in exactly the same way as the original character, so you really shouldn't be interested in them.

提交回复
热议问题