title: Select all DOM elements with HTMLAgilityPack
body: <p>I have been looking at similar questions and searching on-line but I cannot seem to find a a solution. What I am trying to do is select all the DOM elements in order ( etc.) and then put them into an arraylist or something. </p>
  
  <p>currently I have</p>
  
  <pre><code>public void Parse()
      {
          HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
  
          // There are various options, set as needed
          //htmlDoc.OptionFixNestedTags = true;
  
          // filePath is a path to a file containing the html
          htmlDoc.Load("Test.html");
  
          // Use:  htmlDoc.LoadHtml(xmlString);  to load from a string (was htmlDoc.LoadXML(xmlString)
  
          // ParseErrors is an ArrayList containing any errors from the Load statement
          if (htmlDoc.ParseErrors != null &amp;&amp; htmlDoc.ParseErrors.Count() &gt; 0)
          {
              Console.WriteLine("There was an error parsing the HTML file");
          }
          else
          {
              if (htmlDoc.DocumentNode != null)
              {
                  htmlDoc.DocumentNode.Descendants();
  
                  Console.WriteLine("document node not null");
                  //HtmlAgilityPack.HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body");
  
                  foreach (HtmlNode node in htmlDoc.DocumentNode.Descendants())
                  {
                      Console.WriteLine(node.Name);
                  }
              }
          }
      }
  </code></pre>
  
  <p>The code out puts the name of the node (html, title, image, etc) but it outputs the closing tags as "#text". I assume this is because the tags start with a "/" How can I get a proper readout of all the DOM elements?</p>