Sax parsing and encoding

前端 未结 3 614
醉酒成梦
醉酒成梦 2020-12-10 18:05

I have a contact that is experiencing trouble with SAX when parsing RSS and Atom files. According to him, it\'s as if text coming from the Item elements is truncated at an a

3条回答
  •  一个人的身影
    2020-12-10 18:29

    XML entities generate special events in SAX. You can catch them with a LexicalHandler, though it's generally not necessary. But this explain why can't assume that you will recieve only one characters event per tag. Use a buffer as explained in other answers.

    For instance hello&world will generate the sequence

    • startElement
    • characters hello
    • startEntity
    • characters &
    • endEntity
    • characters world

    Have a look at Auxialiary SAX interface, if you want some more examples. Other special events are external entities, comments, CDATA, etc.

提交回复
热议问题