What if I had a document that had multiple elements with the same name -- how would I retrieve, for instance, the second element?

<doc>
...
 <element name="same">foo</element>
...
 <element name="same">bar</element>
...
 <element name="same">baz</element>
...
</doc>

I'd expect something like //elem[@name='same'][2] to work.

Additionally, how would I find the second from last element in xpath with a variable number of elements with the same name

Edit
Report