26

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.

Francesco Casula
  • 26,184
  • 15
  • 132
  • 131
Santosh kumar
  • 342
  • 1
  • 3
  • 6

1 Answers1

53

Use:

ancestor::node()[3]

or

../../..
Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
  • 7
    +1 for ancestor axe plus position predicate solution that can be parameterized –  Sep 09 '10 at 13:06