title: Select Array of XML Elements based on child element condition
body: <p>I have some XML like the following </p>
  
  <pre><code>&lt;USTrades&gt;
      &lt;USTrade&gt;
          &lt;BalanceAmount&gt;1000&lt;/BalanceAmount&gt;
          &lt;Narratives&gt;
             &lt;Narrative code="1" description="Code 1"/&gt;
             &lt;Narrative code="2" description="Code 2"/&gt;
          &lt;/Narratives&gt;
     &lt;/USTrade&gt;
     &lt;USTrade&gt;
         &lt;BalanceAmount&gt;2000&lt;/BalanceAmount&gt;
         &lt;Narratives&gt;
             &lt;Narrative code="3" description="Code 3"/&gt;
          &lt;/Narratives&gt;
     &lt;/USTrade&gt;
  &lt;/USTrades&gt;
  </code></pre>
  
  <p>I would like to select the sum of the balances where the Narrative code is not equal to 3, so my result with this XML would be 1000. The code below looks like it is selecting the correct Narratives, but i dont know how to then select the correct parent based off of the child condition</p>
  
  <pre><code>var trades = document.Descendants("USTrades").Descendants("Narratives").Descendants("Narrative").Where(n =&gt; (string)n.Attribute("code") != "3");
  </code></pre>