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
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.
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