Android SAX parser not getting full text from between tags

前端 未结 3 678
醉酒成梦
醉酒成梦 2020-11-30 02:29

I\'ve created my own DefaultHandler to parse rss feeds and for most feeds it\'s working fine, however, for ESPN, it is cutting off part of the article url due to the way ESP

3条回答
  •  一整个雨季
    2020-11-30 03:00

    As you can see, it's cutting everything off the url from the ampersand escape code and after.

    From the documentation of the characters() method:

    The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.

    When I write SAX parsers, I use a StringBuilder to append everything passed to characters():

    public void characters (char ch[], int start, int length) {
        if (buf!=null) {
            for (int i=start; i

    Then in endElement(), I take the contents of the StringBuilder and do something with it. That way, if the parser calls characters() several times, I don't miss anything.

提交回复
热议问题