Page 1 of 1

Displaying a Node and its Descendants as xpaths

Posted: Wed Feb 22, 2012 9:27 pm
by pcstockman
I would like to select a node and display it as a series of xpaths, one for each of the terminal descendants. Ideally I would also like to capture this information in a text file for further processing. Is this possible to do?

Peter

Re: Displaying a Node and its Descendants as xpaths

Posted: Fri Feb 24, 2012 7:08 pm
by adrian
Hello,

I'm not sure if I understood the exact result that you want to obtain. An example could be helpful.

If you want the XPaths of all the leaf elements for a given element you can use the XPath toolbar or XPath builder from Oxygen.
Execute this expression:

Code: Select all

//element_name//*[not(descendant::*)]
You will get a result in Oxygen results panel and you can save that either as text or XML. One of the fields(description) from the results contains the XPath of each element. The result is of the form:
XPath - content
e.g.

Code: Select all

<incident>
<description>/personnel[1]/person[1]/name[1]/given[1] - Big</description>
<systemID>file:/D:/projects/eXml/samples/personal.xml</systemID>
<location>
<start>
<line>9</line>
<column>13</column>
</start>
<end>
<line>9</line>
<column>31</column>
</end>
</location>
</incident>
Regards,
Adrian