Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XPATH selecting the root element

Tags:

xml

xpath

Is there a simple way of moving back to the root node within any given context. The XML document I'm working with is extremely large and would require using ../.. about a dozen times!!

Any help is greatly appreciated guys.

like image 959
heymega Avatar asked Feb 29 '12 10:02

heymega


People also ask

How do I select the first child in XPath?

The key part of this XPath is *[1] , which will select the node value of the first child of Department .

What will be the XPath expression to select?

XPath uses path expressions to select nodes or node-sets in an XML document. The node is selected by following a path or steps.


1 Answers

An XPath expression starting with / is always referring to the root element. Look here for the syntax and some useful sample queries

If you want to select the root element itself, simply use /<element name> or /*

like image 114
Frank Bollack Avatar answered Sep 22 '22 15:09

Frank Bollack