title: XElement.Elements() extension method?
body: <p>I have an XML file that is loaded into an XElement.  I want to count the number of PollEvent children that both exist and that satisfy some conditions.  I have got the code working to count the number of PollEvents in total but when I come to filter this list I do not seem to be able to call .Where, I believe this to is due to .Elements returning (extension) <code>IEnumerable&lt;XElements&gt;</code>.</p>
  
  <p>Here is the code so far - I have placed what I want to happen next in comments.</p>
  
  <pre><code>    public PollDayPoint LoadData(DateTime date)
      {
          PollDayPoint newDayPoint = new PollDayPoint();
          newDayPoint.Date = date;
  
          String filename = AlertLogging.CreateFileName(date);
  
          XElement xmlDoc = XElement.Load(filename);
  
          IEnumerable&lt;XElement&gt; sdis = xmlDoc.Elements("SDI");
          IEnumerable&lt;XElement&gt; pollEvents = sdis.Elements("PollEvent");
  
          //This works
          int count = 0;
          using (IEnumerator&lt;XElement&gt; enumerator = pollEvents.GetEnumerator())
              while (enumerator.MoveNext())
                  count++;
  
          newDayPoint.NumPolls = count;
  
          //Now we want to get all poll events that match certain conditions
          //Match those that have "Alert" children with attribute status="Sent"
  
          //IEnumerable&lt;XElement&gt; alertEvents = sdis.Elements("PollEvent");
  
          return newDayPoint;
      }
  </code></pre>
  
  <p>Some example XML below</p>
  
  <pre><code>&lt;PollEvents&gt;
    &lt;SDI address="10.1.12.52"&gt;
      &lt;PollEvent time="2009_4_11 13:51:49"&gt;
        &lt;Alert errorCode="System.Net.WebException" errormessage="The remote server returned an error: (504) Gateway Timeout." status="Sent" handletime="2009_4_11 13:51:49" /&gt;
      &lt;/PollEvent&gt;
      &lt;PollEvent time="2009_4_11 14:06:47"&gt;
        &lt;Alert errorCode="System.Net.WebException" errormessage="The remote server returned an error: (504) Gateway Timeout." status="Supressed" handletime="2009_4_11 14:06:47" /&gt;
      &lt;/PollEvent&gt;
      &lt;PollEvent time="2009_4_11 14:21:47"&gt;
        &lt;Alert errorCode="System.Net.WebException" errormessage="The remote server returned an error: (504) Gateway Timeout." status="Supressed" handletime="2009_4_11 14:21:47" /&gt;
      &lt;/PollEvent&gt;
    &lt;/SDI&gt;
  &lt;/PollEvents&gt;
  </code></pre>