私はvb.netにこのようなコードを持っています
Dim str As String
Dim xmlText As String = File.ReadAllText(Server.MapPath("~/reply.xml"))
Dim doc As New XmlDocument()
doc.LoadXml(xmlText)
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(doc.NameTable)
nsmgr.AddNamespace("ns1", "http://schemas.xmlsoap.org/soap/envelope/")
nsmgr.AddNamespace("soapenv", "http://schemas.xmlsoap.org/soap/envelope/")
Dim root As XmlElement = doc.DocumentElement
Dim node As XmlNode = root.SelectSingleNode("//soapenv:Body", nsmgr)
Dim s As String = node.InnerXml
私にとっては問題なく動作します。soapenv:Bodyノードの内部xml全体を抽出できますが、soapenv:Bodyノードのサブ子ノードを抽出したいと思います。
これに対する私の表現は次のようなものです:
Dim node As XmlNode = root.SelectSingleNode("//soapenv:Body/ns1:OTA_AirLowFareSearchRS/ns1:PricedItineraries", nsmgr)
しかし、それは何も抽出していません。私のxmlは次のようなものです:
<?xml version="1.0" encoding="utf-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:OTA_AirLowFareSearchRS Version="2.001" xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:ns1="http://www.opentravel.org/OTA/2003/05">
<ns1:Success />
<ns1:PricedItineraries>
<ns1:PricedItinerary CompositeFlightNumber="S2" CountCompositeFlightNumber="1" FareType="Non-Refundable" InboundSegmentReference="1" MatrixFare="true" Mode="" OriginDestinationRPH="BLRMAAS242336620130329" OutboundSegmentReference="1" Priority="1" RecommendationRPH="1" Refundable="true" ReturnOnly="false" SequenceNumber="1.0" SupplierCode="1AWS">
<ns1:AirItinerary SupplierSystem="Amadeus">
<ns1:OriginDestinationOptions>
<ns1:OriginDestinationOption Duration="00:45:00" FlightID="BLRMAAS24233662013-03-29" MajorityCarrier="S2" ReturnOnly="false" SupplierCode="1AWS" SupplierSystem="Amadeus" UniqueIdentifier="1.0">
<ns1:FlightSegment ArrivalDateTime="2013-03-29T20:20:00" CabinCode="Y" DeliveryMethod="Courier" DepartureDateTime="2013-03-29T19:35:00" Duration="00:45:00" FlightNumber="4233" LTD="1AWS" LineNumber="Y" NumberInParty="BLRMAA" RPH="1" ResBookDesigCode="G" TicketType="Physical" ValidConnectionInd="1AWS">
<ns1:DepartureAirport AirPortName="Bengaluru" CityName="Bangalore" LocationCode="BLR" />
<ns1:ArrivalAirport AirPortName="Chennai" CityName="Chennai" LocationCode="MAA" Terminal="D" />
<ns1:OperatingAirline Code="S2" />
<ns1:BookingClassAvail FareType="RP" ResBookDesigCode="G" ResBookDesigQuantity="7" Status="7" WebFareName="G2SAP30" />
<ns1:Equipment AirEquipType="739" />
<ns1:MarketingAirline Code="S2" MatrixCode="66" Name="JetKonnect" YTAirlineCode="77" />
<ns1:ValidatingCarrier Code="S2" />
</ns1:FlightSegment>
<ns1:FormData>
<ns1:FBC Destination="MAA" FlightNumber="4233" LineNumber="Y" Origin="BLR" SeatToSell="7" WebFareName="G2SAP30" />
<ns1:FareDifference>
<ns1:TotalFare ADT="2" BaseFare="1140-ADT 570" CHD="0" Cabin="Economy" HostName="railserver" INF="0" Rbd="RP - G -" Tax="TTL-4806">5957</ns1:TotalFare>
</ns1:FareDifference>
<ns1:TicketingInfo DeliveryMethod="Courier" TicketTimeLimit="2013-03-05 4:19:00" TicketType="Physical" />
<ns1:AgentMarkup>
<ns1:Airlines>
:
:
:
: