title: LINQ XML - Select all parent elements where a child has a given value
body: <p>From the XML below,  I need to find information about all flights where  FlightSegmentReference ref equals BA2759,  and then pass some details from the parent elements to a class</p>
  
  <pre><code> If Len(inFlightNo) &gt; 0 Then
       Dim xdoc As XDocument = XDocument.Parse(rawXML)
       Dim results As IEnumerable(Of Offer) =
           From offer In xdoc.Descendants(myns + "FlightSegmentReference")
               Where offer.Attribute("ref") = inFlightNo
                   Select New Offer With
                   {.FlightRef = offer.Attribute("ref")}
       'Return results
   End If
  </code></pre>
  
  <p>This example works fine...  however I need to get more data to  pass to my class,  such as TotalAmount SimpleCurrancyPrice and OfferItemID</p>
  
  <pre><code> If Len(inFlightNo) &gt; 0 Then
       Dim xdoc As XDocument = XDocument.Parse(rawXML)
       Dim results As IEnumerable(Of Offer) =
           From offer In xdoc.Descendants(myns + "FlightSegmentReference")
               Where offer.Attribute("ref") = inFlightNo
                   Select New Offer With
                   {.FlightRef = offer.Attribute("ref"),
                    .Price = ????,
                    .OfferItemID = ????
                   }
       'Return results
   End If
  </code></pre>
  
  <p>What is the best practice method of getting SimpleCurrencyPrice and populating Price in my class</p>
  
  <p>Here is the XML</p>
  
  <pre><code>&lt;AirlineOffers&gt;
     &lt;TotalOfferQuantity&gt;1156&lt;/TotalOfferQuantity&gt;
     &lt;Owner&gt;BA&lt;/Owner&gt;
     &lt;AirlineOffer RequestedDateInd="true"&gt;
        &lt;OfferID Owner="BA"&gt;OFFER1&lt;/OfferID&gt;
        &lt;TotalPrice&gt;
           &lt;SimpleCurrencyPrice Code="GBP"&gt;129.50&lt;/SimpleCurrencyPrice&gt;
        &lt;/TotalPrice&gt;
        &lt;PricedOffer&gt;
           &lt;OfferPrice OfferItemID="1"&gt;
              &lt;RequestedDate&gt;
                 &lt;PriceDetail&gt;
                    &lt;TotalAmount&gt;
                       &lt;SimpleCurrencyPrice Code="GBP"&gt;129.50&lt;/SimpleCurrencyPrice&gt;
                    &lt;/TotalAmount&gt;
                    &lt;BaseAmount Code="GBP"&gt;84.00&lt;/BaseAmount&gt;
                    &lt;Taxes&gt;
                       &lt;Total Code="GBP"&gt;45.50&lt;/Total&gt;
                    &lt;/Taxes&gt;
                 &lt;/PriceDetail&gt;
                 &lt;Associations&gt;
                    &lt;AssociatedTraveler&gt;
                       &lt;TravelerReferences&gt;SH1&lt;/TravelerReferences&gt;
                    &lt;/AssociatedTraveler&gt;
                 &lt;/Associations&gt;
              &lt;/RequestedDate&gt;
           &lt;/OfferPrice&gt;
           &lt;Associations&gt;
              &lt;ApplicableFlight&gt;
                 &lt;FlightSegmentReference ref="BA2759"&gt;
                    &lt;ClassOfService&gt;
                       &lt;Code&gt;O&lt;/Code&gt;
                       &lt;MarketingName&gt;Euro Traveller&lt;/MarketingName&gt;
                    &lt;/ClassOfService&gt;
                 &lt;/FlightSegmentReference&gt;
              &lt;/ApplicableFlight&gt;
              &lt;PriceClass&gt;
                 &lt;PriceClassReference&gt;Plus&lt;/PriceClassReference&gt;
              &lt;/PriceClass&gt;
           &lt;/Associations&gt;
           &lt;Associations&gt;
              &lt;ApplicableFlight&gt;
                 &lt;FlightSegmentReference ref="BA2764"&gt;
                    &lt;ClassOfService&gt;
                       &lt;Code&gt;Q&lt;/Code&gt;
                       &lt;MarketingName&gt;Euro Traveller&lt;/MarketingName&gt;
                    &lt;/ClassOfService&gt;
                 &lt;/FlightSegmentReference&gt;
              &lt;/ApplicableFlight&gt;
              &lt;PriceClass&gt;
                 &lt;PriceClassReference&gt;Plus&lt;/PriceClassReference&gt;
              &lt;/PriceClass&gt;
           &lt;/Associations&gt;
        &lt;/PricedOffer&gt;
     &lt;/AirlineOffer&gt;
     &lt;AirlineOffer RequestedDateInd="true"&gt;
        &lt;OfferID Owner="BA"&gt;OFFER2&lt;/OfferID&gt;
        &lt;TotalPrice&gt;
           &lt;SimpleCurrencyPrice Code="GBP"&gt;129.50&lt;/SimpleCurrencyPrice&gt;
        &lt;/TotalPrice&gt;
        &lt;PricedOffer&gt;
           &lt;OfferPrice OfferItemID="1"&gt;
              &lt;RequestedDate&gt;
                 &lt;PriceDetail&gt;
                    &lt;TotalAmount&gt;
                       &lt;SimpleCurrencyPrice Code="GBP"&gt;129.50&lt;/SimpleCurrencyPrice&gt;
                    &lt;/TotalAmount&gt;
                    &lt;BaseAmount Code="GBP"&gt;84.00&lt;/BaseAmount&gt;
                    &lt;Taxes&gt;
                       &lt;Total Code="GBP"&gt;45.50&lt;/Total&gt;
                    &lt;/Taxes&gt;
                 &lt;/PriceDetail&gt;
                 &lt;Associations&gt;
                    &lt;AssociatedTraveler&gt;
                       &lt;TravelerReferences&gt;SH1&lt;/TravelerReferences&gt;
                    &lt;/AssociatedTraveler&gt;
                 &lt;/Associations&gt;
              &lt;/RequestedDate&gt;
           &lt;/OfferPrice&gt;
           &lt;Associations&gt;
              &lt;ApplicableFlight&gt;
                 &lt;FlightSegmentReference ref="BA2765"&gt;
                    &lt;ClassOfService&gt;
                       &lt;Code&gt;O&lt;/Code&gt;
                       &lt;MarketingName&gt;Euro Traveller&lt;/MarketingName&gt;
                    &lt;/ClassOfService&gt;
                 &lt;/FlightSegmentReference&gt;
              &lt;/ApplicableFlight&gt;
              &lt;PriceClass&gt;
                 &lt;PriceClassReference&gt;Plus&lt;/PriceClassReference&gt;
              &lt;/PriceClass&gt;
           &lt;/Associations&gt;
           &lt;Associations&gt;
              &lt;ApplicableFlight&gt;
                 &lt;FlightSegmentReference ref="BA2764"&gt;
                    &lt;ClassOfService&gt;
                       &lt;Code&gt;Q&lt;/Code&gt;
                       &lt;MarketingName&gt;Euro Traveller&lt;/MarketingName&gt;
                    &lt;/ClassOfService&gt;
                 &lt;/FlightSegmentReference&gt;
              &lt;/ApplicableFlight&gt;
              &lt;PriceClass&gt;
                 &lt;PriceClassReference&gt;Plus&lt;/PriceClassReference&gt;
              &lt;/PriceClass&gt;
           &lt;/Associations&gt;
        &lt;/PricedOffer&gt;
     &lt;/AirlineOffer&gt;
  &lt;/AirlineOffers&gt;
  </code></pre>