title: Counting the number of elements in an XML document
body: <p>I am wondering if it is possible to count the number of elements in an XML document preferably being able to fitler using something similar to <code>where (string)query.Attribute("attName") == att</code>.</p>
  
  <p>Using the best of my knowledge i have tried the following but unfortunatly i can't seem to make it work.</p>
  
  <pre><code>                        var listElements = reader.Elements("shortlist");
  
                          foreach (var element in listElements)
                          {
                              XElement _xml;
                              location.Position = 0;
                              System.IO.StreamReader file = new System.IO.StreamReader(location);
                              _xml = XElement.Parse(file.ReadToEnd());
                              XAttribute attName = _xml.Attribute("attN");
  
                               if (attName.Value == att)
                              {
                                  Count++;
                              }                              
                          }
  </code></pre>
  
  <p>Thanks!</p>