I would like to find a span with a specific Id and retrieve the inner text. But I can't seem to find the way to do that.
can someone guide me with this
You may try something along the lines:
var doc = new HtmlDocument();
doc.Load("foo.html");
var node = doc.DocumentNode.SelectSingleNode("//span[@id='foo']");
if (node != null)
{
var innerText = node.InnerText;
}
I personally prefer to turn the whole thing into an XElement and query it that way when using Html Agility. Easier than xpath IMHO. But Darin's answer works
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With