Serhii
Serhii

Reputation: 439

XPath select element if other not exist

In some case we need to select input[@class="some"] element, but only if div[@class="other"] is not exist. Both elements doesn't have common parent, except body, of course.

As soon as results of our environment focused on XPath we need only XPath solution.

UPD: if element exists nothing should be returned

Upvotes: 3

Views: 2965

Answers (1)

hr_117
hr_117

Reputation: 9627

Try (not tested):

 input[@class="some"][not(//div[@class="other"])]

Upvotes: 5

Related Questions