解析在Android中使用SAX无法正常工作的属性

时间:2011-04-05 00:29:08

标签: android xml parsing sax

我有startElement方法的以下代码

@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;
            }
        }
    }

我正在检查媒体宽度以解析现有图像中较大的图像 问题是解析器只解析第一个项目的媒体,并将其用于以下所有项目。有人认为出了什么问题?

0 个答案:

没有答案