xml - How to get a specific node value with xpath when id is in element instead of attribute? -
with xpath /levels/level[@id="3"]/value
can value of level id=3 this:
<levels> <level id="2"> <value>25</value> </level> <level id="3"> <value>33</value> </level> <level id="4"> <value>44</value> </level> </levels>
but xml reading formatted without attributes this:
<levels> <level> <id>2</id> <value>25</value> </level> <level> <id>3</id> <value>33</value> </level> <level> <id>4</id> <value>44</value> </level> </levels>
what equivalent xpath second xml block value of level id=3? (it not guaranteed id=3 second node.)
how following:
/levels/level[id/text() = "3"]/value
or
/levels/level[id/. = "3"]/value