views:

16

answers:

2

Let us have a xml tree of depth N. I have traveresd the last node means i am at last note. Now i wanted to go back to some level up (say at N-3) in the xml tree from that last node.

Please let me know the syntax for the XPATH query so that i can reached at intended node in the xml tree.

A: 

Just like in file systems you can use .. to refer to the parent node. So the query ../../../ will refer to the node three levels up.

musiKk
Thanks for the valuable input.
Santosh kumar
@musikk: except for the final `/`.
LarsH
+2  A: 

Use:

ancestor::node()[3]

or

../../..
Dimitre Novatchev
@Dimitre: +1 for ancestor axe plus position predicate solution that can be parameterized
Alejandro