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

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

How can I get all tr elements without id attribute?

...
...
...

Than

4条回答
  •  旧时难觅i
    2021-01-30 01:58

    Pretty straightforward:

    //tr[not(@id) and not(@class)]
    

    That will give you all tr elements lacking both id and class attributes. If you want all tr elements lacking one of the two, use or instead of and:

    //tr[not(@id) or not(@class)]
    

    When attributes and elements are used in this way, if the attribute or element has a value it is treated as if it's true. If it is missing it is treated as if it's false.

提交回复
热议问题