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 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 Sergey Alexandrovich Kryukov 725
1 OriginalGriff 385
2 CPallini 240
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,835
1 Sergey Alexandrovich Kryukov 5,198
2 CPallini 4,740
3 George Jonsson 3,167
4 Gihan Liyanage 2,470


Advertise | Privacy | Mobile
Web04 | 2.8.140916.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