title: Find parent from descendant attribute xml linq?
body: <p>I'm trying to capture Elements with a child decendent attribute == value</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          XDocument doc = XDocument.Load(@"path to doc");
          var query = from q in doc.Elements("Candidates").Elements("Candidates")
                      //How to filter based on descendant attribute value
                      where (string)q.Descendants("CandidatesPropertyValue")
                      .Attributes["PropertyValue"] != "Consumer Sales &amp; Information"
                      //? this doesn't work obviously
                      select q;
          string type;
          string val;
          foreach (var record in query)
          {
              foreach (XAttribute a in record.Element("Candidates").Attributes())
              {
                  Console.WriteLine("{0} = \"{1}\"", a.Name.ToString(), a.Value.ToString());
              }
              foreach (XElement e in record.Descendants())
              {
                  type = (string)e.Attribute("PropertyType").Value;
                  val = (string)e.Attribute("PropertyValue").Value;
                  Console.WriteLine("     {0} = \"{1}\"", type, val);
              }
          }
          Console.ReadLine();
      }
  
  &lt;CandidatesRoot&gt;
        I WANT THIS ELEMENT
  - &lt;Candidates ...bunch of attributes...&gt;
    &lt;CandidatesPropertyValue PropertyType="Type1" PropertyValue="Value1" /&gt; 
    &lt;CandidatesPropertyValue PropertyType="Type2" PropertyValue="Value2" /&gt; 
    &lt;CandidatesPropertyValue PropertyType="Type3" PropertyValue="Value3" /&gt; 
    &lt;CandidatesPropertyValue PropertyType="Type4" PropertyValue="Value4" /&gt; 
    &lt;CandidatesPropertyValue PropertyType="Type5" PropertyValue="Value5" /&gt; 
    &lt;/Candidates&gt;
        BUT I DON'T WANT THIS ONE
  - &lt;Candidates ...bunch of attributes...&gt;
    &lt;CandidatesPropertyValue PropertyType="Type1" PropertyValue="Value1" /&gt;
    &lt;CandidatesPropertyValue PropertyType="LineOfBusiness" PropertyValue="Consumer Sales &amp; Information" /&gt;
    &lt;CandidatesPropertyValue PropertyType="Type2" PropertyValue="Value2" /&gt; 
    &lt;CandidatesPropertyValue PropertyType="Type3" PropertyValue="Value3" /&gt; 
    &lt;CandidatesPropertyValue PropertyType="Type4" PropertyValue="Value4" /&gt; 
    &lt;CandidatesPropertyValue PropertyType="Type5" PropertyValue="Value5" /&gt; 
    &lt;/Candidates&gt;
  </code></pre>