12

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

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

do?

Stephan Bauer
  • 9,120
  • 5
  • 36
  • 58
kiki
  • 323
  • 2
  • 5
  • 11

1 Answers1

23

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

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • 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