XPath to find elements that does not have an id or class

后端 未结 4 1249
时光取名叫无心
时光取名叫无心 2021-01-30 01:26

How can I get all tr elements without id attribute?

...
...
...

Than

4条回答
  •  一个人的身影
    2021-01-30 02:06

    If you're looking for an element that has class a but doesn't have class b, you can do the following.

    //*[contains(@class, 'a') and not(contains(@class, 'b'))]
    

    Or if you want to be sure not to match partial.

    //*[contains(concat(' ', normalize-space(@class), ' '), ' some-class ') and 
    not(contains(concat(' ', normalize-space(@class), ' '), ' another-class '))]
    

提交回复
热议问题