I've this HTML code:
div class="singolo-contenuto link_azure">
<p><img src="" class="left pad2 field_foto" alt="" /><p> Message </p>
</div>
I need to "capture" "Message". I'm trying with:
String message = htmlDoc.DocumentNode.SelectSingleNode("//div[@class='singolo-contenuto link_azure']").InnerText;
but doesn't works... I obtain a lot of the full page... what's wrong?
The XPath expression you have just gets you to the <div>
tag. You need to get deeper into the last <p>
tag. This will work:
var message = htmlDoc.DocumentNode.SelectSingleNode("//div[@class='singolo-contenuto link_azure']//p[last()]").InnerText;