You were almost there. You don't need []
s around the img
sub-path:
//div[@class="product" and not(img[@alt = "sold out"])]
Another way to write essentially the same thing is:
//div[@class="product" and not(img/@alt = "sold out")]
Lastly, since class
attributes can contain more than one class, it's often better to use contains()
to check for classes:
//div[contains(concat(' ', @class, ' '), " product ") and not(img/@alt = "sold out")]
Post a Comment for "Xpath Expression To Select Nodes Based On Presence Of Child Node?"