Reputation: 9103
I want to search an attribute value that exists in an XML file using XPath, for example to search in the nodes values you type "//ex1/ex2/ex3/text()" but what if i want to get the value of a parameter exists in a node,
let's consider a want to get humidity from the following XML data:
<?xml version="1.0" encoding="UTF-8"?>
-<rss version="2.0" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<!-- api6.weather.ch1.yahoo.com Thu May 16 06:04:56 PST 2013 -->
-<channel>
<language>en-us</language>
<ttl>60</ttl>
<yweather:atmosphere pressure="29.97" visibility="3.73" rising="0" humidity="73"/> <yweather:astronomy sunset="6:41 pm" sunrise="4:59 am"/>
</channel>
</rss>
Upvotes: 0
Views: 1892
Reputation: 27996
You could use //*/@humidity
. That would give you all humidity
attribute nodes, everywhere in the document.
Upvotes: 2
Reputation: 80166
You would use //atmosphere/@humidity
. GO through this XPath syntax tutorial.
Upvotes: 0