title: Filtering your LINQ to XML query
body: <p>I have the following:</p>
  
  <pre><code>XDocument xdoc = XDocument.Load("C:\\myfile.xml");
  
  List&lt;Tag&gt; list = new List&lt;Tag&gt;();
  
  foreach (var tag in xdoc.Descendants("META"))
  
  {
  
  string name = tag.Attribute("name").Value;
  
  string value = tag.Element("value").Value;
  
  list.Add(new Tag { Name = name, Value = value, Score = score, Key = key });
  
  }
  </code></pre>
  
  <p>but I need to only get the META elements under the element ARTICLE.</p>
  
  <p>Can I add this to the linq query somehow?</p>
  
  <p>The xml looks similar to this:</p>
  
  <pre><code>&lt;DOCUMENT&gt;
    &lt;META name="aaa"/&gt;
    &lt;ARTICLE&gt;
     &lt;META name="bbb" value="708" score="0.58" key="6008"/&gt;
    &lt;/ARTICLE&gt;
  &lt;/DOCUMENT&gt;
  </code></pre>
  
  <p>Thanks for any suggestions</p>
  
  <p>In the end I need to do something like the following:</p>
  
  <pre><code>XDocument xdoc = XDocument.Load(tr);
  var meta = from el in xdoc.Descendants("ARTICLE").Elements("META")
  where (string) el.Attribute("name") == "RAW"
  select el;
  
  List&lt;Tag&gt; list = new List&lt;Tag&gt;();
  foreach (var tag in meta)
  {
   string name = tag.Attribute("name").Value;
   string value = tag.Attribute("value").Value;
   string score = tag.Attribute("score").Value;
   string key = tag.Attribute("key").Value;
  
  list.Add(new Tag { Name = name, Value = value, Score = score, Key = key });
  }    
  </code></pre>
  
  <p>The reason for this is that I needed to match the attribute where the name was equal to RAW.</p>
  
  <p>Please correct me if there's a better way to do this!</p>