從下面的XML中,我需要找到有關FlightSegmentReference ref等於BA2759的所有航班的信息,然後將某些細節從父元素傳遞到類LINQ XML - 選擇兒童具有給定值的所有父元素
If Len(inFlightNo) > 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
這個例子正常工作......不過,我需要得到更多的數據傳遞給我的課,如總金額SimpleCurrancyPrice和OfferItemID
If Len(inFlightNo) > 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
什麼是越來越SimpleCurrencyPrice和填充價格的最佳實踐方法在我的班級
這裏是XML
<AirlineOffers>
<TotalOfferQuantity>1156</TotalOfferQuantity>
<Owner>BA</Owner>
<AirlineOffer RequestedDateInd="true">
<OfferID Owner="BA">OFFER1</OfferID>
<TotalPrice>
<SimpleCurrencyPrice Code="GBP">129.50</SimpleCurrencyPrice>
</TotalPrice>
<PricedOffer>
<OfferPrice OfferItemID="1">
<RequestedDate>
<PriceDetail>
<TotalAmount>
<SimpleCurrencyPrice Code="GBP">129.50</SimpleCurrencyPrice>
</TotalAmount>
<BaseAmount Code="GBP">84.00</BaseAmount>
<Taxes>
<Total Code="GBP">45.50</Total>
</Taxes>
</PriceDetail>
<Associations>
<AssociatedTraveler>
<TravelerReferences>SH1</TravelerReferences>
</AssociatedTraveler>
</Associations>
</RequestedDate>
</OfferPrice>
<Associations>
<ApplicableFlight>
<FlightSegmentReference ref="BA2759">
<ClassOfService>
<Code>O</Code>
<MarketingName>Euro Traveller</MarketingName>
</ClassOfService>
</FlightSegmentReference>
</ApplicableFlight>
<PriceClass>
<PriceClassReference>Plus</PriceClassReference>
</PriceClass>
</Associations>
<Associations>
<ApplicableFlight>
<FlightSegmentReference ref="BA2764">
<ClassOfService>
<Code>Q</Code>
<MarketingName>Euro Traveller</MarketingName>
</ClassOfService>
</FlightSegmentReference>
</ApplicableFlight>
<PriceClass>
<PriceClassReference>Plus</PriceClassReference>
</PriceClass>
</Associations>
</PricedOffer>
</AirlineOffer>
<AirlineOffer RequestedDateInd="true">
<OfferID Owner="BA">OFFER2</OfferID>
<TotalPrice>
<SimpleCurrencyPrice Code="GBP">129.50</SimpleCurrencyPrice>
</TotalPrice>
<PricedOffer>
<OfferPrice OfferItemID="1">
<RequestedDate>
<PriceDetail>
<TotalAmount>
<SimpleCurrencyPrice Code="GBP">129.50</SimpleCurrencyPrice>
</TotalAmount>
<BaseAmount Code="GBP">84.00</BaseAmount>
<Taxes>
<Total Code="GBP">45.50</Total>
</Taxes>
</PriceDetail>
<Associations>
<AssociatedTraveler>
<TravelerReferences>SH1</TravelerReferences>
</AssociatedTraveler>
</Associations>
</RequestedDate>
</OfferPrice>
<Associations>
<ApplicableFlight>
<FlightSegmentReference ref="BA2765">
<ClassOfService>
<Code>O</Code>
<MarketingName>Euro Traveller</MarketingName>
</ClassOfService>
</FlightSegmentReference>
</ApplicableFlight>
<PriceClass>
<PriceClassReference>Plus</PriceClassReference>
</PriceClass>
</Associations>
<Associations>
<ApplicableFlight>
<FlightSegmentReference ref="BA2764">
<ClassOfService>
<Code>Q</Code>
<MarketingName>Euro Traveller</MarketingName>
</ClassOfService>
</FlightSegmentReference>
</ApplicableFlight>
<PriceClass>
<PriceClassReference>Plus</PriceClassReference>
</PriceClass>
</Associations>
</PricedOffer>
</AirlineOffer>
</AirlineOffers>
價格和OfferID與所選航段的關係如何?價格代碼似乎在相同的 elelment中,但我沒有看到OfferId是如何相關的。 –