title: What's XmlNodeType.Document ? Difference between XmlNodeType.Element and XmlNodeType.Document
body: <p>I am using XmlReader to read an XML File and I want to count XML Element right under of Document Element that as I know it should be the root element. </p>
  
  <p><strong>XML</strong> </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;NewsLetters&gt;
    &lt;EMail Date="10/10/2009"&gt;hello@hello.com&lt;/EMail&gt;
    &lt;EMail Date="10/10/2009"&gt;hello@hello.com&lt;/EMail&gt;
    &lt;EMail Date="10/10/2009"&gt;hello@hello.com&lt;/EMail&gt;
    &lt;EMail Date="10/10/2009"&gt;hello@hello.com&lt;/EMail&gt;
  &lt;/NewsLetters&gt;
  </code></pre>
  
  <p>C# Code :</p>
  
  <pre><code>public static string TotalMemberCount()
  {
      XmlTextReader reader = new XmlTextReader(HttpContext.Current.Server.MapPath("~/Newsletter/NewsLetter.xml"));
  
      int totalCount = 0;
      while (reader.Read())
      {
          if (reader.NodeType == XmlNodeType.Element &amp;&amp; reader.NodeType != XmlNodeType.Document)
              totalCount++;
      }
  
      return totalCount.ToString();
  }
  </code></pre>
  
  <p><strong>Normally I was expecting 4 records but it returns 5 because it also counts the root element.</strong> What should I do ? Actually I know how to solve with using XDocument,XElement and LINQ but I want to solve in this way, don't ask me why because I want to learn every way in which I can solve such problems.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Sincerely....</p>