tags:

views:

38

answers:

1

I'm hacking the OOXML format with XPath and it contains some 0-based arrays.

What I want to do is get the indices of individual elements.

For example:

<parentNode>
    <childNode type="string" />
    <childNode type="integer" />
    <childNode type="boolean" />
</parentNode>

Here I can find the desired element with the expression "//childNode[@type='boolean']"; now I only need to find it's index with XPath somehow (in this case the index should be 2).

Please advise.

+3  A: 

I would think you should be able to use position() function, but this thread might be helpful to you:

http://stackoverflow.com/questions/226405/find-position-of-a-node-using-xpath

limc