使用SAXParser进行Android XML解析

使用SAXParser进行Android XML解析,android,android-layout,android-intent,saxparser,Android,Android Layout,Android Intent,Saxparser,我有我的RSS文件项: <item > <title>Prasad</title> <link>http://www.tele.com/rssHostDescr.php?hostId=15</link> <guid isPermaLink="false">http://www.tele.com/rssHostDescr.php?hostId=14</guid> <pubDate>2013-04-10&

我有我的RSS文件项:

<item >
<title>Prasad</title>
<link>http://www.tele.com/rssHostDescr.php?hostId=15</link>
<guid isPermaLink="false">http://www.tele.com/rssHostDescr.php?hostId=14</guid>
<pubDate>2013-04-10</pubDate>
<description>Prasad</description>
<media:thumbnail width='66' height='49' url='http://www.tele.com/hos/Panthi-image.jpg'></media:thumbnail>
</item>
<item>
........................
</item>

etc.....................

您需要从属性中读取值,因此它必须位于
startElement

@Override
public void startElement(String uri, String localName, String name,
        Attributes attributes) throws SAXException {
    super.startElement(uri, localName, name, attributes);
    if (localName.equalsIgnoreCase("item")){
        this.currentMessage = new HostsProfile();
    }
    //Validate that localName has the value you want. In theory localName shouldn't have the prefix
    if (localName.equalsIgnoreCase("thumbnail")) { 
      currentMessage.setMediaThumbnail(attributes.getValue("url"));
    }
}   

使用DOM解析器和我有同样的问题…我解决了这个问题!!!你能告诉我消息来源吗Code@altaf我使用了Dom解析器,没有得到值,请检查这个,这里出了什么问题?
else if (localName.equalsIgnoreCase("media:thumbnail")){
                    currentMessage.setMediathumbnail(builder.toString());// During My Program Execution, Here I'm not able to get any value
                }
@Override
public void startElement(String uri, String localName, String name,
        Attributes attributes) throws SAXException {
    super.startElement(uri, localName, name, attributes);
    if (localName.equalsIgnoreCase("item")){
        this.currentMessage = new HostsProfile();
    }
    //Validate that localName has the value you want. In theory localName shouldn't have the prefix
    if (localName.equalsIgnoreCase("thumbnail")) { 
      currentMessage.setMediaThumbnail(attributes.getValue("url"));
    }
}