12

i would like to traverse all nodes in a documnet using HtmlAgilityPack will

foreach (HtmlNode node in myhtml.DocumentNode.SelectNodes("//@"))

do?

Stephan Bauer
  • 8,611
  • 5
  • 37
  • 57
kiki
  • 323
  • 2
  • 5
  • 11

1 Answers1

22

You can just loop through myhtml.DocumentNode.Descendants().

SLaks
  • 837,282
  • 173
  • 1,862
  • 1,933
  • 1
    At least in the current version of HtmlAgilityPack (1.4.9.5), this code won't even compile. Descendants method does not have the overload without parameters. – Alex May 02 '17 at 15:38