Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从这个XML中读取值_C#_Asp.net_Xml_Web Services_Soap - Fatal编程技术网

C# 如何从这个XML中读取值

C# 如何从这个XML中读取值,c#,asp.net,xml,web-services,soap,C#,Asp.net,Xml,Web Services,Soap,我试图从soap响应中读取xml。具体如下 `<OTA_AirLowFareSearchRS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.9.2" PricedItinCount="1" BrandedOneWayItinCount="0" SimpleOneWayItinCount="0" DepartedItin

我试图从soap响应中读取xml。具体如下

`<OTA_AirLowFareSearchRS xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.9.2" PricedItinCount="1" BrandedOneWayItinCount="0" SimpleOneWayItinCount="0" DepartedItinCount="0" SoldOutItinCount="0" AvailableItinCount="0">
    <Success xmlns="http://www.opentravel.org/OTA/2003/05"/>
    <Warnings xmlns="http://www.opentravel.org/OTA/2003/05">...</Warnings>
    <PricedItineraries xmlns="http://www.opentravel.org/OTA/2003/05">
        <PricedItinerary SequenceNumber="1">
                <AirItinerary DirectionInd="OneWay">
                        <OriginDestinationOptions>
                                <OriginDestinationOption ElapsedTime="1920">
                                        <FlightSegment DepartureDateTime="2017-03-21T21:45:00" ArrivalDateTime="2017-03-22T09:50:00" StopQuantity="0" FlightNumber="7336" ResBookDesigCode="T" ElapsedTime="425">
                                                <DepartureAirport LocationCode="CDL" TerminalID="1"/>
                                                <ArrivalAirport LocationCode="CDA" TerminalID="1A"/>
                                                <OperatingAirline Code="AA" FlightNumber="810"/>
                                                <Equipment AirEquipType="000"/>
                                                <MarketingAirline Code="PP"/>
                                                <DisclosureAirline Code="AC"/>
                                                <MarriageGrp>O</MarriageGrp>
                                                <DepartureTimeZone GMTOffset="-10"/>
                                                <ArrivalTimeZone GMTOffset="11"/>
                                                <TPA_Extensions>
                                                        <eTicket Ind="true"/>
                                                </TPA_Extensions>
                                        </FlightSegment>
                                </OriginDestinationOption>
                        </OriginDestinationOptions>
                </AirItinerary>
        </PricedItinerary>
</PricedItineraries>
</OTA_AirLowFareSearchRS>`

任何建议都将受到鼓励。谢谢。

您可以这样编写LINQ查询。您可能需要根据需要调整它,但它可以与XML字符串一起使用

var selected = from x in xdoc.Descendants()
              where x.NodeType == XmlNodeType.Element 
              && x.Name.LocalName == "FlightSegment"
              select x;
这是小提琴手:

var selected = from x in xdoc.Descendants()
              where x.NodeType == XmlNodeType.Element 
              && x.Name.LocalName == "FlightSegment"
              select x;