xpath question
Posted: Fri Feb 24, 2006 10:52 pm
here's my xml:
returns three nodes: two "left" nodes and one "right" node.
/xml//*[@x='y']
returns the two "left" nodes:
/xml//*[@x='y'][1]
returns the "right" node:
/xml//*[@x='y'][2]
returns nothing:
/xml//*[@x='y'][3]
Is there a way i can structure the first query (that returns all three nodes) in such a way that appending the position predicates [1],[2],[3] results in three queries that each uniquely identify a single node?
thanks!
-w
Code: Select all
<xml>
<base>
<left x="y"></left>
<middle></middle>
<right>
<left x="y"></left>
<middle></middle>
<right x="y"></right>
</right>
</base>
</xml>
/xml//*[@x='y']
returns the two "left" nodes:
/xml//*[@x='y'][1]
returns the "right" node:
/xml//*[@x='y'][2]
returns nothing:
/xml//*[@x='y'][3]
Is there a way i can structure the first query (that returns all three nodes) in such a way that appending the position predicates [1],[2],[3] results in three queries that each uniquely identify a single node?
thanks!
-w