title: XmlReader skips elements
body: <p>I have the following code to stream from a large XML file. However, some <code>&lt;Campaign/&gt;</code> elements are skipped. Any reason for this?</p>
  
  <pre><code>public static IEnumerable&lt;XElement&gt; StreamItem(string uri)
  {
      using (var reader = XmlReader.Create(uri))
      {
          XElement campaign = null;
  
          reader.MoveToContent();
  
          // Loop through &lt;Campaign /&gt; elements
          while (reader.Read())
          {
              if (reader.NodeType == XmlNodeType.Element &amp;&amp; reader.Name == "Campaign")
              {
                  campaign = XNode.ReadFrom(reader) as XElement;
                  yield return campaign;
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>Update</strong>:</p>
  
  <p>The XML file is well-formed and has the following structure.</p>
  
  <pre><code>&lt;CRoot&gt;
      &lt;Campaign CampaignID="136"&gt;
          &lt;!-- other nested elements --&gt;
      &lt;/Campaign&gt;
      &lt;Campaign CampaignID="137"&gt;
          &lt;!-- other nested elements --&gt;
      &lt;/Campaign&gt;
      &lt;!-- etc --&gt;
  &lt;/CRoot&gt;
  </code></pre>