CodePlexProject Hosting for Open Source Software
An unexpected error has occured.
There is an unsaved comment in progress. You will lose your changes if you continue. Are you sure you want to reopen the work item?
Voted
No files are attached
kurtnelle wrote Dec 21, 2010 at 1:29 PM
rsturley wrote May 14, 2011 at 11:34 PM
class Program { static void Main(string[] args) { new Program().Run(); } void Run() { string docString = HtmlDocument(); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(docString); // This document has an html tag which had a head and a body. Display the tag hierarchy. DisplayNode(doc.DocumentNode, 0); } void DisplayNode(HtmlNode node, int level) { for (int i = 0; i < level; i++) { Console.Write(" "); } Console.Write("<{0}> <{1}>\n", level, node.OriginalName); foreach (HtmlNode child in node.ChildNodes) DisplayNode(child, level + 1); } string HtmlDocument() { StreamReader reader = new StreamReader("../../test_web_page.html"); string text = reader.ReadToEnd(); reader.Close(); return text; } }
<2> <#text> <2> <head> <3> <#text> <3> <meta> <3> <#text> <2> <#text> <2> <body> <3> <#text> <3> <form> <3> <#text> <3> <input> <3> <#text> <3> <input> <3> <#text> <3> <#text> <3> <#text> <2> <#text>
Sign in to add a comment or to set email notifications
Keyboard shortcuts are available for this page.