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?
Use the operator notand axis descendentto catch h1 tags without even a remote child img.
not
descendent
//h1[not(descendant::img)]
You can use the function not():
not()
//h1[count(img) = 0]
, XHTML, XPath.
h1 img:
h1
img
//h1[not(img)]
//h1[not(.//img)]
which may be easier to understand when reading code.
Try the following XPath expression: