[英]With SAX Parser, get an attribute's value
我正在使用Android從Web解析XML。 下面的代碼顯示了XML的示例。 我遇到的問題是我無法獲取item標簽的字符串值。 當我使用name = attributes.getQName(i);
它輸出名稱,而不是屬性的值。
<weatherdata>
<timetags>
<item name="date">
<value>20/04/2012</value>
<unit/>
<image/>
<class>dynamic</class>
<description>The current date</description>
</item>
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
if(localName.equalsIgnoreCase("item")){
//currentMessage.setMediaUrl(attributes.getValue(BaseFeedParser.Url));
String valueis=attributes.getValue("name")
}
super.startElement(uri, localName, qName, attributes);
}
試試attributes.getValue(i)
方法
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.