Get DIV that has an IMG child with an ALT "dog"?

Viewed 18

Is it possible to get a DIV that has an IMG child with an ALT "dog" with XPath?

....
<div>fake<div>
<div><img alt="cat"/>sike<div>
<div><img alt="dog"/>real<div> <-- get this div
....
1 Answers

Yes, it is possible.
This XPath will do that:

//div[.//img[@alt='dog']]
Related