tags:

views:

216

answers:

2

Is it possible for an xpath selection to return the absolute path for each node found?

for quick example

//chapter

to return

//book[1]/chapter
//book[2]/chapter
...

Thanks

+1  A: 

No easy way to do so just using XPath. If you are using XSLT, there are several recipes available, for instance http://www.dpawson.co.uk/xsl/sect2/N6077.html#d7984e96.

markusk
Have taken a look at that link you've provided and it looks very useful. Thanks.
mysomic
A: 

Pythons lxml module can do it by calling an Elements' getpath method.

SpliFF