In the following HTML snippet:
<div><p class="a b c"></p> <p class="a c"></p> <p class="d"></p> </div>
I want to select only the second p element (with the a class and without the b class) using not selector as follows:
p.a:not(.b)
The xpath counterpart is
.//p[contains(concat(' ', normalize-space(@class), ' '), ' a ')][not(self::*[contains(concat(' ', normalize-space(@class), ' '), ' b ')])].
But when I use that xpath expression, it cannot locate the element.
Is there something else that I can use to achieve the effect of not selector?
Update: It seems I have made a mistake, because p.a:not(.b) and its xpath counterpart do seem to work perfectly for XML::LibXML.
It didn't work because I got one of the if condition wrong…