0

i want to check if there is a certain string in a document, or another certain string. (and then do something) is it possible to use OR in xpath expressions? i tried this:

var xyz = document.evaluate("//dd[contains(., 'year || month')]", document, null, XPathResult.ANY_TYPE, null );
var xyz = headings.iterateNext();
  • Can you provide some code? Generally you have to use `or` instead of `||`. Check here https://stackoverflow.com/questions/12152890/xpath-contains-one-of-multiple-values – Alexander Riedel Apr 21 '20 at 08:58

2 Answers2

1

As @Pete says; or in XPath 2.0+ you can use a regular expression:

//dd[matches(., 'year|month')]

(With XPath questions, please ALWAYS say which version you are using, as it very frequently affects the answer, and all versions are in common use.)

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
0

You can use the or operator:

"//dd[contains(.,'year') or contains(.,'month')]"
Peter
  • 848
  • 8
  • 14