HTML Agility Pack Find a Range

I would like to find a range with a specific identifier and get the inner text. But I can’t find a way to do this.

can anyone help me with this

+4
source share
2 answers

You can try something line by line:

var doc = new HtmlDocument(); doc.Load("foo.html"); var node = doc.DocumentNode.SelectSingleNode("//span[@id='foo']"); if (node != null) { var innerText = node.InnerText; } 
+12
source

I personally prefer turning it all into an XElement and requesting it this way using Html Agility. Lighter than xpath IMHO. But Darin is responding to work

+1
source

Source: https://habr.com/ru/post/1369582/


All Articles