android - XmlPullParser not reach end of document -
im working on simple android app, should fetch rss feeds, read , display information on screen. tried follow google example while implementing code (source: android developers).
my code looks that:
public void fetchxml(string url, context context) { try { url urlobj = new url(url); this.parser = this.xmlpullparserfactory.newpullparser(); inputstream stream = getinputstream(urlobj); string string = this.extractstringfrominputstream(stream); this.parser.setinput(new stringreader(string)); int eventtype = parser.geteventtype(); while (eventtype != xmlpullparser.end_document) { log.i(tag, "value end_document: " + xmlpullparser.end_document + " - eventtype value: " + eventtype); if (parser.geteventtype() != xmlpullparser.start_tag) { continue; } string name = parser.getname(); if (name.equals("title")) { title = readtitle(parser); } if (parser.geteventtype() and!= xmlpullparser.end_tag) { log.i(tag, "im in end tag"); } eventtype = parser.next(); } } catch (exception e) { log.e(tag, "exception: ", e); } }
actually, prints me content of title xml-tag, never stops while-loop. value of eventtype 0. never go xmlpullparser.end_tag.
does knows wrong code?
i found problem myself. has been "continue" part. when delete it, worked.
Comments
Post a Comment