Click here to Skip to main content
11,581,130 members (64,124 online)
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 0:12am
Edited 6-Oct-12 0: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 OriginalGriff 210
1 Frankie-C 195
2 Sergey Alexandrovich Kryukov 85
3 F-ES Sitecore 80
4 Andy Lanng 75
0 OriginalGriff 1,108
1 Sergey Alexandrovich Kryukov 785
2 Abhinav S 622
3 F-ES Sitecore 500
4 Suvendu Shekhar Giri 433


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2015
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