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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.