I'm have HTML file and I'm parsing it with XPath. I'm want to select all [div] nodes which not have [p] tag(s) in it.
For example, input:
<div>
<p>no1</p>
</div>
<div>
<div>
<p>no2</p>
</div>
</div>
<div>
yes!!!
</div>
Expected output:
yes!!!
I'm tried this XPath query, which not working for me:
//div[not (p)]
The xpath:
returns 2
div
Nodes in your sample xml:and your expected one:
You are possibly referencing the xpath in a query where you are expecting just a single node (e.g.
SelectSingleNode
) and therefore just the first node is returned.