Java Android XML解析器值

Java Android XML解析器值,java,xml,Java,Xml,我想知道这部分的价值 <current> <city id="1839071" name="Hoko"> <coord lon="129.34" lat="36.01"/> <country>KR</country> <sun rise="2014-12-24T22:31:10" set="2014-12-25T08:14:18"/> </city> **<temperature value="3.964"

我想知道这部分的价值

<current>
<city id="1839071" name="Hoko">
<coord lon="129.34" lat="36.01"/>
<country>KR</country>
<sun rise="2014-12-24T22:31:10" set="2014-12-25T08:14:18"/>
</city>
**<temperature value="3.964" min="3.964" max="3.964" unit="celsius"/>**
<humidity value="100" unit="%"/>
<pressure value="1031.09" unit="hPa"/>
<wind>
<speed value="9.71" name="Fresh Breeze"/>
<direction value="307.001" code="NW" name="Northwest"/>
</wind>
<clouds value="0" name="clear sky"/>
<visibility/>
<precipitation mode="no"/>
<weather number="800" value="Sky is Clear" icon="01d"/>
<lastupdate value="2014-12-25T07:46:40"/>
</current>

是否正确?

如果文档很小,可以加载文档并使用xpath定位温度节点并达到value属性:

**<temperature value="3.964" min="3.964" max="3.964" unit="celsius"/>**

Weather_temperature = parser.getAttributeValue(null, "value");
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList nodes = (NodeList) xpath.evaluate("/current/temperature", parser, XPathConstants.NODESET);
String temperatureValue = nodes.item(0).getAttribute("value");