Reputation: 836
Here's a minimum reproducible scenario.
<tr> Hello </tr>
<tr class="heisenberg"> I'm the one who knocks. </tr>
<tr class="lennon"> Imagine no errors. </tr>
And I want all the <tr>
except the one with class "heisenberg"
. I did this:
tr[@class!="heisenberg"]
This xpath is selecting lennon
but not the one with empty class. Why ? What should I do to fix this?
Upvotes: 1
Views: 640
Reputation: 4869
Your XPath assumes that node has class
attribute and it is not equal to "heisenberg"
Try this one to select node that doesn't contain specific @class
tr[not(@class="heisenberg")]
If node can contain multiple class names you can also try
tr[not(contains(@class, "heisenberg"))]
Upvotes: 1