1

Having the XML

<node attribute="value1">text</node>

what would be the XPath to extract the text if attribute is value1 or value2? For any other attribute value I'm expecting no match.

What works for me is

/node[@attribute = 'value1' or @attribute = 'value2']/text()

Is there any shorter notation for the same? I don't want to duplicate attribute name twice.

Michal Kordas
  • 10,475
  • 7
  • 58
  • 103

1 Answers1

1

If your xpath version supports this, use

//node[@attribute=('value1','value2')]
Jack Fleeting
  • 24,385
  • 6
  • 23
  • 45