1

Is it possible to select nodes in a similar way?

'./tr[position() in (1, 3, 7)]'

I found only this solution:

'./tr[position() = 1 or position() = 3 or position() = 7]'
Pyt
  • 1,925
  • 2
  • 13
  • 10
  • possible duplicate of [XPath "in" operator](http://stackoverflow.com/questions/13871250/xpath-in-operator) – har07 Sep 23 '14 at 07:01

1 Answers1

4

In XPath 2.0 you would simply do:

./tr[position = (1,3,7)]

In XPath 1.0 the usual way to do it is the solution you already found, an alternative that is a bit shorter would be something like:

./tr[contains('1 3 7', position())] 

The spaces in the string are essential here, otherwise you'd also get nodes 13,37 and 137.

Tobias Klevenz
  • 1,625
  • 11
  • 13