Attributes parsing not working correctly with SAX in Android
I have the following code for the startElement meth开发者_如何学运维od
@Override
public void startElement(String uri, String localname, String qname,
Attributes atts) throws SAXException {
if (localname.trim().equals("item"))
this.in_item = true;
else if (localname.trim().equals("title"))
this.in_title = true;
else if (localname.trim().equals("link"))
this.in_link = true;
else if (localname.trim().equals("description"))
this.in_description = true;
else if (localname.trim().equals("category"))
this.in_category = true;
else if (localname.trim().equals("pubDate"))
this.in_pubdate = true;
else if ((qname.trim().equals("media:thumbnail")) || (qname.trim().equals("media:content")))
{
this.in_media = true;
String width = atts.getValue("width");
Integer tmp =Integer.parseInt(width);
if (tmp > currentitem.getMedia_width()) {
String link = atts.getValue("url");
currentItem.setmedia() = link;
currentItem.media_width() = tmp;
}
}
}
I am checking the media width to parse the bigger of the existing images the problem is the parser only parses the first item's media, and use it for all the following items.can someone think what's going wrong?
精彩评论