获取SAX解析器的属性值 [英] Getting SAX Parser attributes value
问题描述
快速的问题。我从采用Android网页解析XML。低于$ C $ 1c示出了XML的一种样品。我遇到的问题是我不能item标签的字符串值。当我使用名称= attributes.getQName(我);
它输出的名称,属性不是值。
< weatherdata>
< timetags>
<项目名称=约会>
<价值> 20/04/2012< /值GT;
<单位/>
<图像/>
<类>动态< /类>
<描述>将当前日期和LT; /描述>
< /项目>
任何帮助是非常AP preciated
感谢
马蒂
使用
attributes.getValue(我);
而不是
attributes.getQName(我);
因为作为<一个href="http://developer.android.com/reference/org/xml/sax/helpers/AttributesImpl.html#getQName%28int%29">doc说:
getQName :返回属性的限定(prefixed)名称的
的getValue :查找属性的值由合格的(prefixed)名称的
看<一href="http://examples.java$c$cgeeks.com/core-java/xml/sax/get-element-attributes-in-sax-xml-parsing">this例如用于获取属性名称和值
quick question. I am Parsing XML from the web using Android. The Code below shows a sample of the XML. The problem I'm having is I can't the string value of the item tag. When I use name = attributes.getQName(i);
it outputs name, not the value of the attribute.
<weatherdata>
<timetags>
<item name="date">
<value>20/04/2012</value>
<unit/>
<image/>
<class>dynamic</class>
<description>The current date</description>
</item>
Any help is much appreciated
Thanks
Marty
use
attributes.getValue(i);
instead of
attributes.getQName(i);
because as doc says :
getQName :Return an attribute's qualified (prefixed) name.
getValue : Look up an attribute's value by qualified (prefixed) name.
see this example for getting attribute name and value
这篇关于获取SAX解析器的属性值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!