HtmlDocument doc = new HtmlDocument(); doc.LoadHtml("Hello world!
"); HtmlNode bodyNode = doc.DocumentNode.Descendants("body").FirstOrDefault(); foreach (HtmlNode node in bodyNode.DescendantNodes()) { Console.WriteLine(node.Name); }
HtmlDocument doc = new HtmlDocument(); doc.LoadHtml("This code loads an HTML document with a `title` element and uses `DescendantNodes()` to find the `title` node and print out its inner text. Overall, HtmlAgilityPack is a package library that allows for parsing HTML documents in C# and provides useful methods such as `DescendantNodes()` for accessing and manipulating HTML nodes.Example Hello world!
"); HtmlNode titleNode = doc.DocumentNode.Descendants("title").FirstOrDefault(); Console.WriteLine(titleNode.InnerText);