使用XmlSerializer解析xml时出错

时间:2016-02-29 16:01:18

标签: c# xml xml-parsing xml-serialization

我正在尝试使用XmlSerializer将XML解析为c#对象:

XmlSerializer serialize = new XmlSerializer(typeof(Xml2CSharp.LowFareSearchCorpRsp));
StringReader rdr = new StringReader(tmpRes);
Xml2CSharp.LowFareSearchCorpRsp res = (Xml2CSharp.LowFareSearchCorpRsp)serializer.Deserialize(rdr);

然后我收到下一条错误消息:

  

InnerException = {“LowFareSearchRsp xmlns =''不是预期的。”}

这是对象:

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
namespace Xml2CSharp
{
    [XmlRoot(ElementName = "FlightDetails")]
    public class FlightDetails
    {
        [XmlAttribute(AttributeName = "Key")]
        public string Key { get; set; }
        [XmlAttribute(AttributeName = "Origin")]
        public string Origin { get; set; }
        [XmlAttribute(AttributeName = "Destination")]
        public string Destination { get; set; }
        [XmlAttribute(AttributeName = "DepartureTime")]
        public string DepartureTime { get; set; }
        [XmlAttribute(AttributeName = "ArrivalTime")]
        public string ArrivalTime { get; set; }
        [XmlAttribute(AttributeName = "FlightTime")]
        public string FlightTime { get; set; }
        [XmlAttribute(AttributeName = "TravelTime")]
        public string TravelTime { get; set; }
        [XmlAttribute(AttributeName = "Equipment")]
        public string Equipment { get; set; }
        [XmlAttribute(AttributeName = "DestinationTerminal")]
        public string DestinationTerminal { get; set; }
    }

    [XmlRoot(ElementName = "FlightDetailsList")]
    public class FlightDetailsList
    {
        [XmlElement(ElementName = "FlightDetails")]
        public List<FlightDetails> FlightDetails { get; set; }
    }

    [XmlRoot(ElementName = "BookingCodeInfo")]
    public class BookingCodeInfo
    {
        [XmlAttribute(AttributeName = "BookingCounts")]
        public string BookingCounts { get; set; }
    }

    [XmlRoot(ElementName = "AirAvailInfo")]
    public class AirAvailInfo
    {
        [XmlElement(ElementName = "BookingCodeInfo")]
        public BookingCodeInfo BookingCodeInfo { get; set; }
        [XmlAttribute(AttributeName = "ProviderCode")]
        public string ProviderCode { get; set; }
    }

    [XmlRoot(ElementName = "FlightDetailsRef")]
    public class FlightDetailsRef
    {
        [XmlAttribute(AttributeName = "Key")]
        public string Key { get; set; }
    }

    [XmlRoot(ElementName = "AirSegment")]
    public class AirSegment
    {
        [XmlElement(ElementName = "AirAvailInfo")]
        public AirAvailInfo AirAvailInfo { get; set; }
        [XmlElement(ElementName = "FlightDetailsRef")]
        public FlightDetailsRef FlightDetailsRef { get; set; }
        [XmlAttribute(AttributeName = "Key")]
        public string Key { get; set; }
        [XmlAttribute(AttributeName = "Group")]
        public string Group { get; set; }
        [XmlAttribute(AttributeName = "Carrier")]
        public string Carrier { get; set; }
        [XmlAttribute(AttributeName = "FlightNumber")]
        public string FlightNumber { get; set; }
        [XmlAttribute(AttributeName = "Origin")]
        public string Origin { get; set; }
        [XmlAttribute(AttributeName = "Destination")]
        public string Destination { get; set; }
        [XmlAttribute(AttributeName = "DepartureTime")]
        public string DepartureTime { get; set; }
        [XmlAttribute(AttributeName = "ArrivalTime")]
        public string ArrivalTime { get; set; }
        [XmlAttribute(AttributeName = "FlightTime")]
        public string FlightTime { get; set; }
        [XmlAttribute(AttributeName = "Distance")]
        public string Distance { get; set; }
        [XmlAttribute(AttributeName = "ETicketability")]
        public string ETicketability { get; set; }
        [XmlAttribute(AttributeName = "Equipment")]
        public string Equipment { get; set; }
        [XmlAttribute(AttributeName = "ChangeOfPlane")]
        public string ChangeOfPlane { get; set; }
        [XmlAttribute(AttributeName = "ParticipantLevel")]
        public string ParticipantLevel { get; set; }
        [XmlAttribute(AttributeName = "LinkAvailability")]
        public string LinkAvailability { get; set; }
        [XmlAttribute(AttributeName = "PolledAvailabilityOption")]
        public string PolledAvailabilityOption { get; set; }
        [XmlAttribute(AttributeName = "OptionalServicesIndicator")]
        public string OptionalServicesIndicator { get; set; }
        [XmlAttribute(AttributeName = "AvailabilitySource")]
        public string AvailabilitySource { get; set; }
        [XmlAttribute(AttributeName = "AvailabilityDisplayType")]
        public string AvailabilityDisplayType { get; set; }
        [XmlElement(ElementName = "CodeshareInfo")]
        public CodeshareInfo CodeshareInfo { get; set; }
    }

    [XmlRoot(ElementName = "CodeshareInfo")]
    public class CodeshareInfo
    {
        [XmlAttribute(AttributeName = "OperatingCarrier")]
        public string OperatingCarrier { get; set; }
        [XmlAttribute(AttributeName = "OperatingFlightNumber")]
        public string OperatingFlightNumber { get; set; }
        [XmlText]
        public string Text { get; set; }
    }

    [XmlRoot(ElementName = "AirSegmentList")]
    public class AirSegmentList
    {
        [XmlElement(ElementName = "AirSegment")]
        public List<AirSegment> AirSegment { get; set; }
    }

    [XmlRoot(ElementName = "BaggageAllowance")]
    public class BaggageAllowance
    {
        [XmlElement(ElementName = "NumberOfPieces")]
        public string NumberOfPieces { get; set; }
        [XmlElement(ElementName = "MaxWeight")]
        public string MaxWeight { get; set; }
    }

    [XmlRoot(ElementName = "FareRuleKey")]
    public class FareRuleKey
    {
        [XmlAttribute(AttributeName = "FareInfoRef")]
        public string FareInfoRef { get; set; }
        [XmlAttribute(AttributeName = "ProviderCode")]
        public string ProviderCode { get; set; }
        [XmlText]
        public string Text { get; set; }
    }

    [XmlRoot(ElementName = "FareInfo")]
    public class FareInfo
    {
        [XmlElement(ElementName = "BaggageAllowance")]
        public BaggageAllowance BaggageAllowance { get; set; }
        [XmlElement(ElementName = "FareRuleKey")]
        public FareRuleKey FareRuleKey { get; set; }
        [XmlAttribute(AttributeName = "Key")]
        public string Key { get; set; }
        [XmlAttribute(AttributeName = "FareBasis")]
        public string FareBasis { get; set; }
        [XmlAttribute(AttributeName = "PassengerTypeCode")]
        public string PassengerTypeCode { get; set; }
        [XmlAttribute(AttributeName = "Origin")]
        public string Origin { get; set; }
        [XmlAttribute(AttributeName = "Destination")]
        public string Destination { get; set; }
        [XmlAttribute(AttributeName = "EffectiveDate")]
        public string EffectiveDate { get; set; }
        [XmlAttribute(AttributeName = "DepartureDate")]
        public string DepartureDate { get; set; }
        [XmlAttribute(AttributeName = "Amount")]
        public string Amount { get; set; }
        [XmlAttribute(AttributeName = "NegotiatedFare")]
        public string NegotiatedFare { get; set; }
        [XmlAttribute(AttributeName = "PrivateFare")]
        public string PrivateFare { get; set; }
        [XmlAttribute(AttributeName = "NotValidBefore")]
        public string NotValidBefore { get; set; }
        [XmlAttribute(AttributeName = "NotValidAfter")]
        public string NotValidAfter { get; set; }
        [XmlAttribute(AttributeName = "PseudoCityCode")]
        public string PseudoCityCode { get; set; }
    }

    [XmlRoot(ElementName = "FareInfoList")]
    public class FareInfoList
    {
        [XmlElement(ElementName = "FareInfo")]
        public List<FareInfo> FareInfo { get; set; }
    }

    [XmlRoot(ElementName = "Leg")]
    public class Leg
    {
        [XmlAttribute(AttributeName = "Key")]
        public string Key { get; set; }
        [XmlAttribute(AttributeName = "Group")]
        public string Group { get; set; }
        [XmlAttribute(AttributeName = "Origin")]
        public string Origin { get; set; }
        [XmlAttribute(AttributeName = "Destination")]
        public string Destination { get; set; }
    }

    [XmlRoot(ElementName = "Route")]
    public class Route
    {
        [XmlElement(ElementName = "Leg")]
        public Leg Leg { get; set; }
        [XmlAttribute(AttributeName = "Key")]
        public string Key { get; set; }
    }

    [XmlRoot(ElementName = "RouteList")]
    public class RouteList
    {
        [XmlElement(ElementName = "Route")]
        public Route Route { get; set; }
    }

    [XmlRoot(ElementName = "AirSegmentRef")]
    public class AirSegmentRef
    {
        [XmlAttribute(AttributeName = "Key")]
        public string Key { get; set; }
    }

    [XmlRoot(ElementName = "Journey")]
    public class Journey
    {
        [XmlElement(ElementName = "AirSegmentRef")]
        public AirSegmentRef AirSegmentRef { get; set; }
        [XmlAttribute(AttributeName = "TravelTime")]
        public string TravelTime { get; set; }
    }

    [XmlRoot(ElementName = "LegRef")]
    public class LegRef
    {
        [XmlAttribute(AttributeName = "Key")]
        public string Key { get; set; }
    }

    [XmlRoot(ElementName = "FareInfoRef")]
    public class FareInfoRef
    {
        [XmlAttribute(AttributeName = "Key")]
        public string Key { get; set; }
    }

    [XmlRoot(ElementName = "BookingInfo")]
    public class BookingInfo
    {
        [XmlAttribute(AttributeName = "BookingCode")]
        public string BookingCode { get; set; }
        [XmlAttribute(AttributeName = "CabinClass")]
        public string CabinClass { get; set; }
        [XmlAttribute(AttributeName = "FareInfoRef")]
        public string FareInfoRef { get; set; }
        [XmlAttribute(AttributeName = "SegmentRef")]
        public string SegmentRef { get; set; }
    }

    [XmlRoot(ElementName = "TaxInfo")]
    public class TaxInfo
    {
        [XmlAttribute(AttributeName = "Category")]
        public string Category { get; set; }
        [XmlAttribute(AttributeName = "Amount")]
        public string Amount { get; set; }
    }

    [XmlRoot(ElementName = "PassengerType")]
    public class PassengerType
    {
        [XmlAttribute(AttributeName = "Code")]
        public string Code { get; set; }
        [XmlAttribute(AttributeName = "Age")]
        public string Age { get; set; }
    }

    [XmlRoot(ElementName = "ChangePenalty")]
    public class ChangePenalty
    {
        [XmlElement(ElementName = "Amount")]
        public string Amount { get; set; }
    }

    [XmlRoot(ElementName = "AirPricingInfo")]
    public class AirPricingInfo
    {
        [XmlElement(ElementName = "FareInfoRef")]
        public FareInfoRef FareInfoRef { get; set; }
        [XmlElement(ElementName = "BookingInfo")]
        public BookingInfo BookingInfo { get; set; }
        [XmlElement(ElementName = "TaxInfo")]
        public List<TaxInfo> TaxInfo { get; set; }
        [XmlElement(ElementName = "FareCalc")]
        public string FareCalc { get; set; }
        [XmlElement(ElementName = "PassengerType")]
        public PassengerType PassengerType { get; set; }
        [XmlElement(ElementName = "ChangePenalty")]
        public ChangePenalty ChangePenalty { get; set; }
        [XmlAttribute(AttributeName = "Key")]
        public string Key { get; set; }
        [XmlAttribute(AttributeName = "TotalPrice")]
        public string TotalPrice { get; set; }
        [XmlAttribute(AttributeName = "BasePrice")]
        public string BasePrice { get; set; }
        [XmlAttribute(AttributeName = "ApproximateTotalPrice")]
        public string ApproximateTotalPrice { get; set; }
        [XmlAttribute(AttributeName = "ApproximateBasePrice")]
        public string ApproximateBasePrice { get; set; }
        [XmlAttribute(AttributeName = "Taxes")]
        public string Taxes { get; set; }
        [XmlAttribute(AttributeName = "ApproximateTaxes")]
        public string ApproximateTaxes { get; set; }
        [XmlAttribute(AttributeName = "LatestTicketingTime")]
        public string LatestTicketingTime { get; set; }
        [XmlAttribute(AttributeName = "PricingMethod")]
        public string PricingMethod { get; set; }
        [XmlAttribute(AttributeName = "ETicketability")]
        public string ETicketability { get; set; }
        [XmlAttribute(AttributeName = "PlatingCarrier")]
        public string PlatingCarrier { get; set; }
        [XmlAttribute(AttributeName = "ProviderCode")]
        public string ProviderCode { get; set; }
    }

    [XmlRoot(ElementName = "AirPricingSolution")]
    public class AirPricingSolution
    {
        [XmlElement(ElementName = "Journey")]
        public Journey Journey { get; set; }
        [XmlElement(ElementName = "LegRef")]
        public LegRef LegRef { get; set; }
        [XmlElement(ElementName = "AirPricingInfo")]
        public AirPricingInfo AirPricingInfo { get; set; }
        [XmlAttribute(AttributeName = "Key")]
        public string Key { get; set; }
        [XmlAttribute(AttributeName = "TotalPrice")]
        public string TotalPrice { get; set; }
        [XmlAttribute(AttributeName = "BasePrice")]
        public string BasePrice { get; set; }
        [XmlAttribute(AttributeName = "ApproximateTotalPrice")]
        public string ApproximateTotalPrice { get; set; }
        [XmlAttribute(AttributeName = "ApproximateBasePrice")]
        public string ApproximateBasePrice { get; set; }
        [XmlAttribute(AttributeName = "Taxes")]
        public string Taxes { get; set; }
        [XmlAttribute(AttributeName = "ApproximateTaxes")]
        public string ApproximateTaxes { get; set; }
    }

    [XmlRoot(ElementName = "LowFareSearchRsp")]
    public class LowFareSearchRsp
    {
        [XmlElement(ElementName = "FlightDetailsList")]
        public FlightDetailsList FlightDetailsList { get; set; }
        [XmlElement(ElementName = "AirSegmentList")]
        public AirSegmentList AirSegmentList { get; set; }
        [XmlElement(ElementName = "FareInfoList")]
        public FareInfoList FareInfoList { get; set; }
        [XmlElement(ElementName = "RouteList")]
        public RouteList RouteList { get; set; }
        [XmlElement(ElementName = "AirPricingSolution")]
        public List<AirPricingSolution> AirPricingSolution { get; set; }
        [XmlAttribute(AttributeName = "TransactionId")]
        public string TransactionId { get; set; }
        [XmlAttribute(AttributeName = "ResponseTime")]
        public string ResponseTime { get; set; }
        [XmlAttribute(AttributeName = "DistanceUnits")]
        public string DistanceUnits { get; set; }
        [XmlAttribute(AttributeName = "CurrencyType")]
        public string CurrencyType { get; set; }
        [XmlAttribute(AttributeName = "air", Namespace = "http://www.w3.org/2000/xmlns/")]
        public string Air { get; set; }
    }

}

这是XML:

<LowFareSearchRsp TransactionId="2D7A0AD80A07643BB75C03CA78C9877F" ResponseTime="2378" DistanceUnits="MI" CurrencyType="EUR" xmlns:air="http://www.travelport.com/schema/air_v28_0"><FlightDetailsList><FlightDetails Key="Q0tqCkHxQfqBJpSbN+LtXQ==" Origin="AMS" Destination="LHR" DepartureTime="2016-03-01T08:35:00.000+01:00" ArrivalTime="2016-03-01T09:00:00.000+00:00" FlightTime="85" TravelTime="85" Equipment="737" DestinationTerminal="4" /><FlightDetails Key="w1vkvs2sQayOxIHugEe06Q==" Origin="AMS" Destination="LCY" DepartureTime="2016-03-01T08:45:00.000+01:00" ArrivalTime="2016-03-01T09:00:00.000+00:00" FlightTime="75" TravelTime="75" Equipment="AR8" /><FlightDetails Key="F5zR9xf/TEe8sjwHe0Lgfg==" Origin="AMS" Destination="LCY" DepartureTime="2016-03-01T08:00:00.000+01:00" ArrivalTime="2016-03-01T08:10:00.000+00:00" FlightTime="70" TravelTime="70" Equipment="AR8" /></FlightDetailsList><AirSegmentList><AirSegment Key="0uT0Eex8R+q0AGhindSZJw==" Group="0" Carrier="KL" FlightNumber="1007" Origin="AMS" Destination="LHR" DepartureTime="2016-03-01T08:35:00.000+01:00" ArrivalTime="2016-03-01T09:00:00.000+00:00" FlightTime="85" Distance="211" ETicketability="Yes" Equipment="737" ChangeOfPlane="false" ParticipantLevel="Secure Sell" LinkAvailability="true" PolledAvailabilityOption="Polled avail used" OptionalServicesIndicator="false" AvailabilitySource="S" AvailabilityDisplayType="Fare Shop/Optimal Shop"><AirAvailInfo ProviderCode="1G"><BookingCodeInfo BookingCounts="J5|C4|D3|I3|Z2|Y9|B9|M9|U9|K9|W9|H0|S9|L0|A0|Q0|T0|E0|N0|R0|V0|X0|G0" /></AirAvailInfo><FlightDetailsRef Key="Q0tqCkHxQfqBJpSbN+LtXQ==" /></AirSegment><AirSegment Key="Xou2ll85S+qgxInLw5cppA==" Group="0" Carrier="KL" FlightNumber="2404" Origin="AMS" Destination="LCY" DepartureTime="2016-03-01T08:45:00.000+01:00" ArrivalTime="2016-03-01T09:00:00.000+00:00" FlightTime="75" Distance="211" ETicketability="Yes" Equipment="AR8" ChangeOfPlane="false" ParticipantLevel="Secure Sell" LinkAvailability="true" PolledAvailabilityOption="Polled avail used" OptionalServicesIndicator="false" AvailabilitySource="S" AvailabilityDisplayType="Fare Shop/Optimal Shop"><CodeshareInfo OperatingCarrier="WX" OperatingFlightNumber="184">CITY JET</CodeshareInfo><AirAvailInfo ProviderCode="1G"><BookingCodeInfo BookingCounts="J9|C9|D9|I9|Z9|Y9|B9|M9|U9|K9|W9|H9|S9|L6|A9|Q9|T6|E0|N0|R0|V0|G0" /></AirAvailInfo><FlightDetailsRef Key="w1vkvs2sQayOxIHugEe06Q==" /></AirSegment><AirSegment Key="1w6HTv96SXWWuLY0Pe2QuQ==" Group="0" Carrier="KL" FlightNumber="2402" Origin="AMS" Destination="LCY" DepartureTime="2016-03-01T08:00:00.000+01:00" ArrivalTime="2016-03-01T08:10:00.000+00:00" FlightTime="70" Distance="211" ETicketability="Yes" Equipment="AR8" ChangeOfPlane="false" ParticipantLevel="Secure Sell" LinkAvailability="true" PolledAvailabilityOption="Polled avail used" OptionalServicesIndicator="false" AvailabilitySource="S" AvailabilityDisplayType="Fare Shop/Optimal Shop"><CodeshareInfo OperatingCarrier="WX" OperatingFlightNumber="182">CITY JET</CodeshareInfo><AirAvailInfo ProviderCode="1G"><BookingCodeInfo BookingCounts="J9|C9|D9|I9|Z9|Y9|B9|M9|U9|K9|W9|H9|S9|L6|A9|Q9|T6|E0|N0|R0|V0|G0" /></AirAvailInfo><FlightDetailsRef Key="F5zR9xf/TEe8sjwHe0Lgfg==" /></AirSegment></AirSegmentList><FareInfoList><FareInfo Key="/2JzpaPgR4GHLl4HEnIiZg==" FareBasis="KBAGYNL" PassengerTypeCode="ADT" Origin="AMS" Destination="LHR" EffectiveDate="2016-02-29T15:41:00.000+01:00" DepartureDate="2016-03-01" Amount="EUR133.00" NegotiatedFare="false" PrivateFare="AirlinePrivateFare" NotValidBefore="2016-03-01" NotValidAfter="2016-03-01" PseudoCityCode="7LD2"><BaggageAllowance><NumberOfPieces>1</NumberOfPieces><MaxWeight /></BaggageAllowance><FareRuleKey FareInfoRef="/2JzpaPgR4GHLl4HEnIiZg==" ProviderCode="1G">6UUVoSldxwglWqQxEnyq/cbKj3F8T9EyxsqPcXxP0TIjSPOlaHfQe9/ilBar8RBLwtrZnoOgR1cYHR4az4coGwd2gmBPo1O6ASmIQpER2x0wNY5k1+MQrLCjWzPlFL6jYBR1VjXHCoG1PqzaFGsJo/E8Wy+Z6VUptu1Q7ZKxyGrtZySrXDhOpdi8VZ+tr8Yjcw61JCjZInRzWhUTy56VK0Y+V0ELMq+/Sutrg11uaZNEQ+ZLml8hMrbyQOwi+ESbfUKpUJwmWYGbGOyXec3aXsoJsodpwGFHJHXyDAS6XXKrSeiEQqx4y86wIJ070sjSq2Mkfg7v2+hW8vSBNa8ZUuJYtF79PC3YsxYLUKGiXKW7eP3a4bhHZA0g8fgZiGj0Vesixah9noHg2BMJ0qOmdc4YTCgtCVCcN49GIwD0nwinN0QJSoeu5/wBShF29N4Sv4Xvb2u1Qx+/he9va7VDH7+F729rtUMfv4Xvb2u1Qx8Qxibp/OJehpo2LrM59tO1jp8ZENljzx72lVAJ3nO/P4n+Mxf03TJScktxA0VgKcbS+gYtjsYoLmbFZUBdXZs1</FareRuleKey></FareInfo><FareInfo Key="vOp7x5iCTnaOfEJmIceWdQ==" FareBasis="HBAGYNL" PassengerTypeCode="ADT" Origin="AMS" Destination="LCY" EffectiveDate="2016-02-29T15:41:00.000+01:00" DepartureDate="2016-03-01" Amount="EUR294.00" NegotiatedFare="false" PrivateFare="AirlinePrivateFare" NotValidBefore="2016-03-01" NotValidAfter="2016-03-01" PseudoCityCode="7LD2"><BaggageAllowance><NumberOfPieces>1</NumberOfPieces><MaxWeight /></BaggageAllowance><FareRuleKey FareInfoRef="vOp7x5iCTnaOfEJmIceWdQ==" ProviderCode="1G">6UUVoSldxwglWqQxEnyq/cbKj3F8T9EyxsqPcXxP0TIjSPOlaHfQe/r7UOc8hVd+I/+NqP0rKzLusgtyd1y6qgP9G0W6IHlhpqZ6lb6AP0xNjTzzGmA6/Urra4NdbmmTzFOd+W7w/UzJ2lQug+wKWM3BdGL2xyFSNsm3fw/kMAOxMmAX3SbpGDy3fBfc+mJVEPaEs+237t0eSBuiOpSk/gzsLeFdZfeBzi5JKGVGwBPPOvXkrT+ckAxdqLsZnUAM83fZ3yCAPapY9YklFLj9Z/MCXrZl6G/oVCulqMwbpNbfH3zc0NhSMKqdj8Ih8qyqVnAnvWMa00Sdw/Am9T/DRMsiOHFaFMf8GWXoXHIgLpyVqfCTByZWB+lREtwo3mkOzK0Iy0HMiGbqNbjwzJx7oqPv19h9EZpQEQ4DmK2C6uFH/+bkQTnfvoq+cJFUBzrily5qxZ3qLwOXLmrFneovA5cuasWd6i8Dly5qxZ3qLwOXLmrFneovA3N5jV9Rrzq8txHW6jzw2UbAQJCzzE4cyQuLI8q+Wie1FwDp7I8hPtiGaLihfOSYJ8Bo4QYxmFzt</FareRuleKey></FareInfo></FareInfoList><RouteList><Route Key="rX1yXg7iR4+opM4/Ol7rrw=="><Leg Key="NYqOScjGQESvuXuIGUjFqg==" Group="0" Origin="AMS" Destination="LON" /></Route></RouteList><AirPricingSolution Key="uIwAvUxtTuK4hqFLGAnJaQ==" TotalPrice="EUR160.05" BasePrice="EUR133.00" ApproximateTotalPrice="EUR160.05" ApproximateBasePrice="EUR133.00" Taxes="EUR27.05" ApproximateTaxes="EUR27.05"><Journey TravelTime="P0DT1H25M0S"><AirSegmentRef Key="0uT0Eex8R+q0AGhindSZJw==" /></Journey><LegRef Key="NYqOScjGQESvuXuIGUjFqg==" /><AirPricingInfo Key="8DDuD5q9TTWmR6+Y1QIPuQ==" TotalPrice="EUR160.05" BasePrice="EUR133.00" ApproximateTotalPrice="EUR160.05" ApproximateBasePrice="EUR133.00" Taxes="EUR27.05" ApproximateTaxes="EUR27.05" LatestTicketingTime="2016-03-01T23:59:00.000+01:00" PricingMethod="GuaranteedUsingAirlinePrivateFare" ETicketability="Yes" PlatingCarrier="KL" ProviderCode="1G"><FareInfoRef Key="/2JzpaPgR4GHLl4HEnIiZg==" /><BookingInfo BookingCode="K" CabinClass="Economy" FareInfoRef="/2JzpaPgR4GHLl4HEnIiZg==" SegmentRef="0uT0Eex8R+q0AGhindSZJw==" /><TaxInfo Category="CJ" Amount="EUR12.17" /><TaxInfo Category="RN" Amount="EUR14.38" /><TaxInfo Category="VV" Amount="EUR0.50" /><FareCalc>AMS KL LON 144.81KBAGYNL NUC144.81END ROE0.918404</FareCalc><PassengerType Code="ADT" Age="20" /><ChangePenalty><Amount>EUR70.00</Amount></ChangePenalty></AirPricingInfo></AirPricingSolution><AirPricingSolution Key="4Og1WgNSQf6r7WHXpetyqA==" TotalPrice="EUR321.05" BasePrice="EUR294.00" ApproximateTotalPrice="EUR321.05" ApproximateBasePrice="EUR294.00" Taxes="EUR27.05" ApproximateTaxes="EUR27.05"><Journey TravelTime="P0DT1H15M0S"><AirSegmentRef Key="Xou2ll85S+qgxInLw5cppA==" /></Journey><LegRef Key="NYqOScjGQESvuXuIGUjFqg==" /><AirPricingInfo Key="hauIf2TLRE+xSFkaJa1bAQ==" TotalPrice="EUR321.05" BasePrice="EUR294.00" ApproximateTotalPrice="EUR321.05" ApproximateBasePrice="EUR294.00" Taxes="EUR27.05" ApproximateTaxes="EUR27.05" LatestTicketingTime="2016-03-01T23:59:00.000+01:00" PricingMethod="GuaranteedUsingAirlinePrivateFare" ETicketability="Yes" PlatingCarrier="KL" ProviderCode="1G"><FareInfoRef Key="vOp7x5iCTnaOfEJmIceWdQ==" /><BookingInfo BookingCode="H" CabinClass="Economy" FareInfoRef="vOp7x5iCTnaOfEJmIceWdQ==" SegmentRef="Xou2ll85S+qgxInLw5cppA==" /><TaxInfo Category="CJ" Amount="EUR12.17" /><TaxInfo Category="RN" Amount="EUR14.38" /><TaxInfo Category="VV" Amount="EUR0.50" /><FareCalc>AMS KL LON 320.12HBAGYNL NUC320.12END ROE0.918404</FareCalc><PassengerType Code="ADT" Age="20" /><ChangePenalty><Amount>EUR70.00</Amount></ChangePenalty></AirPricingInfo></AirPricingSolution><AirPricingSolution Key="VD1GnxpWQJi/4emcBGZTKQ==" TotalPrice="EUR321.05" BasePrice="EUR294.00" ApproximateTotalPrice="EUR321.05" ApproximateBasePrice="EUR294.00" Taxes="EUR27.05" ApproximateTaxes="EUR27.05"><Journey TravelTime="P0DT1H10M0S"><AirSegmentRef Key="1w6HTv96SXWWuLY0Pe2QuQ==" /></Journey><LegRef Key="NYqOScjGQESvuXuIGUjFqg==" /><AirPricingInfo Key="OvfECYiLRraifkOqyl1qGA==" TotalPrice="EUR321.05" BasePrice="EUR294.00" ApproximateTotalPrice="EUR321.05" ApproximateBasePrice="EUR294.00" Taxes="EUR27.05" ApproximateTaxes="EUR27.05" LatestTicketingTime="2016-03-01T23:59:00.000+01:00" PricingMethod="GuaranteedUsingAirlinePrivateFare" ETicketability="Yes" PlatingCarrier="KL" ProviderCode="1G"><FareInfoRef Key="vOp7x5iCTnaOfEJmIceWdQ==" /><BookingInfo BookingCode="H" CabinClass="Economy" FareInfoRef="vOp7x5iCTnaOfEJmIceWdQ==" SegmentRef="1w6HTv96SXWWuLY0Pe2QuQ==" /><TaxInfo Category="CJ" Amount="EUR12.17" /><TaxInfo Category="RN" Amount="EUR14.38" /><TaxInfo Category="VV" Amount="EUR0.50" /><FareCalc>AMS KL LON 320.12HBAGYNL NUC320.12END ROE0.918404</FareCalc><PassengerType Code="ADT" Age="20" /><ChangePenalty><Amount>EUR70.00</Amount></ChangePenalty></AirPricingInfo></AirPricingSolution></LowFareSearchRsp>
我坚持下去了。 请帮忙。

1 个答案:

答案 0 :(得分:3)

在您的代码中进行小编辑后,它对我来说很好用:

XmlSerializer serialize = new XmlSerializer(typeof(UnitTestProject.LowFareSearchRsp));
StringReader rdr = new StringReader(xml);
LowFareSearchRsp res = (LowFareSearchRsp)serialize.Deserialize(rdr);

很快,您的资源类型错误:LowFareSearchCorpRsp而不是LowFareSearchRsp