SAXParser '&' concatenation problem

折月煮酒 提交于 2019-12-01 05:54:13

The SAX API does not guarantee that any given text node will be delivered in one piece. It is permitted to break it up into multiple calls to the characters() method. Your application has to accommodate this possibly, and reassemble the pieces itself.

Incidentally, Nation Created Our World & everything in it is not a valid XML text fragment, it would have to be Nation Created Our World & everything in it. In this case the SAX parser may be breaking it up into Nation Created Our World, & and everything in it, and your app is only remembering the last one.

Thanks skaffman

Implementation,

public void startElement(String s, String s1, String elementName, Attributes attributes) throws SAXException {
    // clear tmpValue on start of element
    tmpValue = "";
}

public void characters(char[] ac, int i, int j) throws SAXException {
    tmpValue += new String(ac, i, j);
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!