Search code examples
xpathoperator-keywordprefix

combine two xpath expretion with the same prefix


I'm trying to find some way to merge the result of two xpath queries with the same prefix.

Say: /inventory/product/itemNumber | /inventory/product/itemName

I'm looking for something like /inventory/product/(itemNumber | itemName) (the order of the output is irreverent for me).

Basically, I'm trying to find a way not to write the long prefix twice.

Thanx!


Solution

  • The way to accomplish this is the following:

    /inventory/product/*[self::itemNumber or self::itemName]