Assume we have this simple xml ...
<books>
<book>
<author/>
<title/>
</book>
<book>
<author/>
<title/>
</book>
</books>
I'm using this xpath to get the elements of the first book instance.
//books[1]/*
Returns
<author/>
<title/>
And that works fine, but I have to get it working using local-name(). I've tried the following but none of these work...
//*[local-name()='books']/*
this returns repeating author and title elements, not good, I only need them from the first child
//*[local-name()='books'][0]/*
this does not return anything
Basically, I want to create a CSV file, so the first line in the output will be a header listing the book attribute names followed by the arbitrary data values. I only need to get the header part working.
author,title
john,The End is Near
sally,Looking for Answers
//books[1]/*
should return two book elements, not an author and a title element. So there is some confusion somewhere. – Elegance