none
How to check subnode is present if get the value in linq to xml? RRS feed

  • General discussion

  • 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}         // One or more FlightSegment Value.

                                FlightSegement[1]{ArrivalDate,DepartureDate}

    PricedItinerary[1]->FlightSegement[0]{ArrivalDate,DepartureDate}

    PricedItinerary[2]->FlightSegement[0]{ArrivalDate,DepartureDate}

                                FlightSegement[1]{ArrivalDate,DepartureDate}

    The list goes on.,

    Please let me know if u need more information.

    Thanks in advance.


    Saturday, October 6, 2012 10:33 AM

All replies

  • Hi Thirisangu;

    Please change the type of thread from a discussion to a question, there should be a radio button option to do that on the question.

    The posted XML document is invalid because none of the nodes have a end tag. Also all the nodes are associated to a name space ns1 but in the XML fragment a name space is not given.

    It would be nice if you can post an entire document so that we can test a solution with. If a XML document is to large to post please zip it and upload to your SkyDrive and post a link here to the download.

       


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".


    Saturday, October 6, 2012 4:57 PM