Basically I want to select a node (div) in which it contains the children of the node (h1, b, h3) containing the specified text.
<html>
<div id="contents">
<p>
<h1> Child text 1</h1>
<b> Child text 2 </b>
...
</p>
<h3> Child text 3 </h3>
</div>
I expect / html / div / not / html / div / h 1
I have this below, but unfortunately returns the children instead of the xpath in the div.
expression = "//div[contains(text(), 'Child text 1')]"
doc.xpath(expression)
I expect / html / div / not / html / div / h 1
So, is there a way to do this simply with xpath syntax?
ajfjaj
source
share