Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use XPath to select an element that doesn't have an img tag as a child

Tags:

xpath

Is it possible to select an h1 tag that does not contain any img tags with a single line XPath expression? If so, what is it?

like image 766
Peter Horne Avatar asked Jan 02 '10 23:01

Peter Horne


1 Answers

Use the not operator and the descendent axis to catch h1 tags without even a distant img child.

//h1[not(descendant::img)]
like image 67
Andrew Arnott Avatar answered Jan 04 '23 01:01

Andrew Arnott