这是我正在使用的 XML 有多个 LineItemDetails 实例我只发布了其中一个...
<LineItemDetail>
<DetailNumber>1</DetailNumber>
<LineItemNumber>1</LineItemNumber>
<BatchSequenceNumber>1</BatchSequenceNumber>
<RecordSequenceWithinBatch>1</RecordSequenceWithinBatch>
<ChargeAmount Name="GrossBilled">365.380</ChargeAmount>
<Tax>
<TaxType>Tax</TaxType>
<TaxAmount Name="Billed">15.630</TaxAmount>
<TaxBreakdown>
<TaxCode>MN</TaxCode>
<TaxAmount Name="Billed">15.630</TaxAmount>
</TaxBreakdown>
</Tax>
<AddOnCharges>
<AddOnChargeName>ISCAllowed</AddOnChargeName>
<AddOnChargePercentage>-9</AddOnChargePercentage>
<AddOnChargeAmount>-32.880</AddOnChargeAmount>
</AddOnCharges>
<TotalNetAmount>348.130</TotalNetAmount>
<CouponDetails>
<TicketOrFIMIssuingAirline>160</TicketOrFIMIssuingAirline>
<TicketOrFIMCouponNumber>1</TicketOrFIMCouponNumber>
<TicketDocOrFIMNumber>2649488544</TicketDocOrFIMNumber>
<CheckDigit>6</CheckDigit>
<CurrAdjustmentIndicator>USD</CurrAdjustmentIndicator>
<ElectronicTicketIndicator>E</ElectronicTicketIndicator>
<AirlineFlightDesignator>MR</AirlineFlightDesignator>
<FlightNo>885</FlightNo>
<FlightDate>2013-04-03</FlightDate>
<FromAirportCode>ULN</FromAirportCode>
<ToAirportCode>HKG</ToAirportCode>
<SettlementAuthorizationCode>861FBKOPVEZZ4</SettlementAuthorizationCode>
<Attachment>
<AttachmentIndicatorOriginal>N</AttachmentIndicatorOriginal>
</Attachment>
</CouponDetails>
</LineItemDetail>
以上是 XML 文档。我需要检索标签的值<TaxCode>
。
直到现在我已经走到了这一步
var tax = from d in doc.Root.Descendants("Tax") select d;
foreach (var p in tax)
{
taxcode= p.Element("TaxCOde").Value;
}