title: XmlReader skipping some blocks
body: <p>I have an xml structured like this:</p>
  
  <pre><code>Header
    \-Timeseries (1-N)
          \- Period (1-N)
                \- Interval (1-N)
  </code></pre>
  
  <p>This is an approximate example:</p>
  
  <pre><code>&lt;Header&gt;
  &lt;Element /&gt;
      &lt;Timeseries&gt;
         &lt;Element /&gt;
         &lt;Period&gt;
             &lt;Element /&gt;
             &lt;Interval&gt;
                 &lt;Element /&gt;
             &lt;/Interval&gt;
         &lt;/Period&gt;
      &lt;/Timeseries&gt;
  &lt;/Header&gt;
  </code></pre>
  
  <p>I'm hoping to read the header elements until I hit Timeseries, then Timeseries elements until I hit Period, then Period until I hit Interval, and Interval until I hit the end of the Interval. When I'm finished with a Period, I'm writing all Intervals.</p>
  
  <p>This particular document has 614 Timeseries with 1 Period per each Timeseries.</p>
  
  <p>I'm parsing it with:</p>
  
  <pre><code>while (!xmlReader.EOF)
  {
      if (xmlReader.NodeType == XmlNodeType.Element &amp;&amp; xmlReader.Name == "Header")
      {
          while (xmlReader.Name != "Timeseries" &amp;&amp; xmlReader.Read())
          {
              // read
          }
      }
      else if (xmlReader.NodeType == XmlNodeType.Element &amp;&amp; xmlReader.Name == "Timeseries")
      {
          while (xmlReader.Name != "Period" &amp;&amp; xmlReader.Read())
          {
              // read
          }           
      }
      else if (xmlReader.NodeType == XmlNodeType.Element &amp;&amp; xmlReader.Name == "Period")
      {
          while (xmlReader.Name != "Interval" &amp;&amp; xmlReader.Read())
          {
              // read
          }
      }
      else if (xmlReader.NodeType == XmlNodeType.Element &amp;&amp; xmlReader.Name == "Interval")
      {
          while (xmlReader.NodeType != XmlNodeType.EndElement &amp;&amp; xmlReader.Read())
          {
              // read
          }
      }
      else if (xmlReader.NodeType == XmlNodeType.EndElement &amp;&amp; xmlReader.Name == "Period")
      {
          // write intervals
      }
      else
      {
          xmlReader.Read();
      }
  }
  </code></pre>
  
  <p>It appears that only 166/614 Periods are read. Therefore I must be gobbling up some xml, but am having trouble spotting the error.</p>
  
  <p>Dumping the read shows that Timeseries 1-166 are correctly parsed, but somehow the parsing stops after that.</p>