biox
biox

Reputation: 1566

How to ignore first and last element in xpath

How to ignore first and last element in xpath? Couldnt find any example on the internet. I only found that you can use [position()>1] to ignore first element but how i can ignore last too?

Upvotes: 11

Views: 6910

Answers (2)

paul trmbrth
paul trmbrth

Reputation: 20748

Try [position()>1 and position()<last()]

Upvotes: 15

Ian Roberts
Ian Roberts

Reputation: 122414

You can use

[postion() < last()]

(if the expression appears in an XML document, for example an XSLT stylesheet, then you'll need to escape the < as &lt;)

Upvotes: 4

Related Questions