public static void Main()
<h1>This is <b>bold</b> heading</h1>
<p>This is <u>underlined</u> paragraph</p>
<p id='test'>This a single paragraph with a line break.</p>
<div>This is another paragraph <span>with an inline</span> format part.</p>
var htmlDoc = new HtmlDocument();
var htmlBody = htmlDoc.DocumentNode.SelectSingleNode("//body");
var nodeCount = htmlBody.ChildNodes.Count - 1;
Console.WriteLine(htmlBody.ChildNodes.Count);
Console.WriteLine("There is not child element");
Console.WriteLine("Enter number smaller or equal to " + nodeCount +":");
string userName = Console.ReadLine();
HtmlNode node = htmlBody.ChildNodes[nodeCount];
Console.WriteLine("\n****After removing a node from parent node****\n");
Console.WriteLine("\n****Removed node****\n");
if (node.NodeType == HtmlNodeType.Element)
Console.WriteLine("Node is not type of element.");
static void DisplayNode(HtmlNode node)
Console.WriteLine("Node Name: " + node.Name);
Console.Write("\n" + node.Name + " children:\n");
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.OuterHtml);