Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6379101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:05:40+00:00 2026-05-25T02:05:40+00:00

I am getting the flight details from the expedia API, please check the link

  • 0

I am getting the flight details from the expedia API, please check the link below for the XML format.

The result output contains Rateinfo then flight details as separate node and there is no relation between rateinfo and flightsegment.
Normally I load the XML into dataset and use the dataset to populate the records, but in this case there is no relation between rate and flight segment, how will I parse this XML in C#. I need to show the user the flight segments and the corresponding rates.

http://api.ean.com/ean-services/rs/air/200919/xmlinterface.jsp?cid=55505&resType=air&intfc=ws&apiKey=fc9hjrvrur9vr4y2dqa249w4&xml=<AirSessionRequest method="getAirAvailability"><AirAvailabilityQuery><originCityCode>MCI</originCityCode><destinationCityCode>CLT</destinationCityCode><departureDateTime>09/01/2011 01:00 AM</departureDateTime><returnDateTime>09/04/2011 01:00 AM</returnDateTime><fareClass>Y</fareClass><tripType>R</tripType><Passengers><adultPassengers>2</adultPassengers></Passengers><xmlResultFormat>1</xmlResultFormat><searchType>2</searchType></AirAvailabilityQuery></AirSessionRequest>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:05:41+00:00Added an answer on May 25, 2026 at 2:05 am

    A dataset represents relational data much easier than hierarchial data, which is what the xml represents, and that is probably the crux of your problem.

    Linq2Xml is one option, or you could create a set of classes that are seriealizable and deserialize the xml into instances of the class, so then you can just iterate through the classes with foreach, or use linq on them.

    I’m not saying this is the best way to go about doing what you need, but it is relatively tidy, and you don’t need to deal with xml, just class instances. I tested this with the xml you provided and it worked quite well, although I do think that the Linq2Xml method might be more performant – Not 100% sure though.

    Assuming your xml is in a variable called sXmlResult:

    public class Test
    {
        public void Run()
        {
            //Load the xml and serialize it into instances of our classes
            System.Xml.Serialization.XmlSerializer ser = new System.Xml.Serialization.XmlSerializer(typeof(AirAvailabilityResults));
    
            System.IO.StringReader sr = new System.IO.StringReader(sXmlResult);
            AirAvailabilityResults results = (AirAvailabilityResults)ser.Deserialize(sr);
    
            //Now we can access all the data like we would any other object.
            foreach (AirAvailabilityReply reply in results.AirAvailabilityReply)
            {
                double dNativeBaseFare = reply.RateInfo.nativeBaseFare;
    
                foreach (FlightSegment segment in reply.FlightSegment)
                {
                    int iFlightNumber = segment.flightNumber;
                }
            }
        }
    }
    
    //Create the seriealizable classes to represent the xml.  
    //I created these by infering the schema from the xml.  These classes may need some changes, if 
    //they don't exactly match the actual schema that expedia uses
    public class AirAvailabilityResults
    {
        [System.Xml.Serialization.XmlElement()]
        public AirAvailabilityReply[] AirAvailabilityReply { get; set; }
    
        [System.Xml.Serialization.XmlAttribute()]
        public int size {get;set;}
    
        [System.Xml.Serialization.XmlElement()]
        public string cacheKey {get;set;}
    
        [System.Xml.Serialization.XmlElement()]
        public string cacheLocation {get;set;}
    
    }
    
    public class AirAvailabilityReply
    {
        public enum SupplierType
        {
            S
        }
        public enum TripType
        {
            R
        }
        public enum TicketType
        {
            E
        }
    
        [System.Xml.Serialization.XmlElement()]
        public SupplierType supplierType {get;set;}
    
        [System.Xml.Serialization.XmlElement()]
        public TripType tripType {get;set;}
    
        [System.Xml.Serialization.XmlElement()]
        public TicketType ticketType {get;set;}
    
        public RateInfo RateInfo { get; set; }
    
        [System.Xml.Serialization.XmlElement()]
        public FlightSegment[] FlightSegment {get;set;}
    }
    
    public class RateInfo
    {
        public double nativeBaseFare {get;set;}
        public double nativeTotalPrice {get;set;}
        public string nativeCurrencyCode { get; set; }
        public double displayBaseFare {get;set;}
        public double displayTotalPrice {get;set;}
        public string displayCurrencyCode { get; set; }
    }
    
    public class FlightSegment
    {
        public bool segmentOutgoing {get;set;}
        public string airlineCode {get;set;}
        public string airline {get;set;}
        public int flightNumber {get;set;}
        public string originCityCode {get;set;}
        public string destinationCityCode {get;set;}
        public string departureDateTime {get;set;}
        public string arrivalDateTime { get; set; }
        public string fareClass {get;set;}
        public string equipmentCode {get;set;}
        public int numberOfStops {get;set;}
        public string originCity {get;set;}
        public string originStateProvince {get;set;}
        public string originCountry {get;set;}
        public string destinationCity {get;set;}
        public string desintationStateProvince {get;set;}
        public string destinationCountry { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting the subdomain from a URL sounds easy at first. http://www.domain.example Scan for the
Getting the above error in following code. How to rectify it. Thanks. Please look
Getting Json from the Server and displaying it in the grid is relatively straight
I'm getting this error, not really sure why. Please help, this is urgent. UPDATE
I want to use Linq to extract data from an XML document and place
Getting frustrated looking for answers for hours on this one... I have an .xml
Getting an Undefined Offset error here -- apparently from the $newval array. Note that
GetToProerty and GetROProerty are geeting property values from OR in QTP, i get below
Getting started with jquery and having trouble getting hello world type example going for
Getting started with NHibernate How can I generate identity fields in nHibernate using Hilo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.