How do you find the tag in the xml and take the meaning of a given attribute?
-
For example, we know the name Z_city1. How do you find the tag he belongs to and take the attribut value, id?
<cities> <country name="N"> <city id="37199" region="98765" head="" type="3" country="N" part="" resort="" climate="">N_city1</city> <city id="37178" region="48317" head="" type="3" country="N" part="" resort="" climate="">N_city2</city> </country> <country name="Z"> <city id="25381" region="12345" head="" type="3" country="Z" part="" resort="" climate="">Z_city1</city> <city id="14888" region="34657" head="" type="3" country="Z" part="" resort="" climate="">Z_city2</city> </country> </cities>
-
by xpath demand:
//*[text()[contains(.,'Z_city1')]]/@id