public static void Main()
<h1>This is <b>bold</b> heading</h1>
<p>This is <u>underlined</u> paragraph</p>
var htmlDoc = new HtmlDocument();
var htmlBody = htmlDoc.DocumentNode.SelectSingleNode("//body");
DisplayChildNodes(htmlBody);
HtmlNode newHtmlBody = htmlBody.CloneNode(false);
Console.WriteLine("\nClone Node Name: " + newHtmlBody.Name);
Console.WriteLine("\n****Display children of the clone node****\n");
DisplayChildNodes(newHtmlBody);
static void DisplayChildNodes(HtmlNode nodeElement)
HtmlNodeCollection childNodes = nodeElement.ChildNodes;
if (childNodes.Count == 0)
Console.WriteLine(nodeElement.Name + " has no children");
foreach (var node in childNodes)
if (node.NodeType == HtmlNodeType.Element)
Console.WriteLine(node.InnerText);