HTML Agility Pack select all header?

html html-agility-pack

Question

I have a complex HTML document, has so many headings, can HTMLAgilityPack select all of headings in one time query? The result should keep the heading's orginal sequence.

Can anyone know this? thanks

1
3
3/12/2014 2:17:01 PM

Accepted Answer

Yes you can do something like this using XPath

var xpath = "//*[self::h1 or self::h2 or self::h3 or self::h4]";
foreach (var node in doc.DocumentNode.SelectNodes(xpath))
{
  //do something
}

This respect the order of the tags too. If you want more tags you can add it to the Xpath expression.

8
3/12/2014 2:38:56 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow