Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# XML LINQ
hi all,
 
This is my xml response.
<ns1:PricedItineraries>
<ns1:PricedItinerary>
<ns1:AirItinerary>
<ns1:OriginDestinationOptions>
<ns1:OriginDestinationOption>
<ns1:FlightSegment ArrivalDateTime="2012-10-07T11:40:00" DepartureDateTime="2012-10-07T10:50:00">
<ns1:BookingClassAvail FareType="RP">
<ns1:FlightSegment ArrivalDateTime="2012-10-07T11:40:00" DepartureDateTime="2012-10-07T10:50:00">
<ns1:BookingClassAvail FareType="RP">
<ns1:OriginDestinationOption>
<ns1:OriginDestinationOptions>
<ns1:AirItinerary>
<ns1:PricedItinerary>
<ns1:PricedItinerary>
<ns1:AirItinerary>
<ns1:OriginDestinationOptions>
<ns1:OriginDestinationOption>
<ns1:FlightSegment ArrivalDateTime="2012-10-08T11:40:00" DepartureDateTime="2012-10-07T10:50:00">
<ns1:BookingClassAvail FareType="RRP">
<ns1:FlightSegment ArrivalDateTime="2012-10-08T11:40:00" DepartureDateTime="2012-10-07T10:50:00">
<ns1:BookingClassAvail FareType="RRP">
<ns1:OriginDestinationOption>
<ns1:OriginDestinationOptions>
<ns1:AirItinerary>
<ns1:PricedItinerary>
<ns1:PricedItineraries>
Here i need to Get the Flightsegement value seperately. Under one pricedItinerary there may be more than one Flightsegment will be there. I have to get the Arrivaldate and Departure date of each Flightsegment separately.
 
These things should come under First PricedItinerary. There Will be more PricedItinerary there,
Desire Output:
PricedItinerary[0];FlightSegement[0]{ArrivalDate,DepartureDate}         FlightSegement[1]{ArrivalDate,DepartureDate}
 
PricedItinerary[1];FlightSegement[0]{ArrivalDate,DepartureDate}
 
PricedItinerary[2];FlightSegement[0]{ArrivalDate,DepartureDate}
FlightSegement[1]{ArrivalDate,DepartureDate}
The list goes on.,
Here,
Posted 6-Oct-12 1:12am
Edited 6-Oct-12 1:28am
v2
Comments
thirisangu at 8-Oct-12 3:28am
   
I got the answer..,

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

var BG = xd.Descendants(ns + "PricedItineraries").Elements(ns + "PricedItinerary").Select(o => string.Join(",", o.Elements(ns + "AirItinerary")
                .Elements(ns + "OriginDestinationOptions").Elements(ns + "OriginDestinationOption")
                .Elements(ns + "FlightSegment").Attributes("ArrivalDateTime"))).ToList<string>();
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 320
1 OriginalGriff 195
2 Afzaal Ahmad Zeeshan 154
3 BillWoodruff 135
4 Peter Leow 115
0 OriginalGriff 7,510
1 DamithSL 5,519
2 Sergey Alexandrovich Kryukov 4,994
3 Maciej Los 4,936
4 Kornfeld Eliyahu Peter 4,514


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100