是否可以在xpath查询中使用OR?想要在一个查询中匹配2个不同的属性

Byr*_*ock 2 xpath

我想做一个匹配两个独立属性的xpath查询.

所以我想匹配//div[@class='foo']/OR//div[@class='bar']/

我怎么做?

Mat*_*hen 6

//div[@class='foo' or @class='bar']
Run Code Online (Sandbox Code Playgroud)

  • +1好答案.此外,这更短:`//div[@class[.='foo'或.='bar']]` (3认同)
  • 仅供参考,对于那些不记得各种xpath结构语法的人,mulberrytech.com上有一页的快速参考卡.非常便利.在http://www.mulberrytech.com/quickref/index.html上找到它. (2认同)