Use XPath to select an item that does not have an img tag as a child

advertisements

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 not operator and the descendent axis to catch h1 tags without even a distant img child.

//h1[not(descendant::img)]