estoy haciendo una aplicación en la que tiene que solicitar la disponibilidad de vuelos y ordenar en un flexgrid o un dtagridview la respuesta, esto es con archivos xml.
la estructura del xml-responce es la siguiente:
Código:
lo que quiero es que lea los nodos de <FlightSegment> y sus respectivos <SellingClass><OriginDestinationOptions> <OriginDestinationOption> <FlightSegment> <ReturnCode>0</ReturnCode> <ODNo>1</ODNo> <SegmentNo>1</SegmentNo> <CityPairNo>62</CityPairNo> <DepartureCity>MEX</DepartureCity> <ArrivalCity>CUN</ArrivalCity> <FlightNumber>AAA3140</FlightNumber> <BoardDate>2014-07-26</BoardDate> <DepartureAirport>MEX</DepartureAirport> <ArrivalAirport>CUN</ArrivalAirport> <FlightPathCode>D</FlightPathCode> <DepartureTime>11:10</DepartureTime> <ArrivalTime>13:25</ArrivalTime> <Classes> <SellingClass> <ClassCode>T</ClassCode> <SeatCount>99</SeatCount> <FareCode>TVA</FareCode> <FareValue>100.00</FareValue> <TaxValue>584.10</TaxValue> <RefundableFlag>0</RefundableFlag> <FloatingFareFlag>0</FloatingFareFlag> <FloatingBaseClass/> <Cabin>Z</Cabin> </SellingClass> <SellingClass> <ClassCode>S</ClassCode> <SeatCount>93</SeatCount> <FareCode>STA</FareCode> <FareValue>110.00</FareValue> <TaxValue>528.92</TaxValue> <RefundableFlag>0</RefundableFlag> <FloatingFareFlag>0</FloatingFareFlag> <FloatingBaseClass/> <Cabin>Z</Cabin> </SellingClass> </Classes> <CodeShare/> </FlightSegment> </OriginDestinationOption> <OriginDestinationOption> <FlightSegment> <ReturnCode>0</ReturnCode> <ODNo>2</ODNo> <SegmentNo>1</SegmentNo> <CityPairNo>62</CityPairNo> <DepartureCity>MEX</DepartureCity> <ArrivalCity>CUN</ArrivalCity> <FlightNumber>AAA3142</FlightNumber> <BoardDate>2014-07-26</BoardDate> <DepartureAirport>MEX</DepartureAirport> <ArrivalAirport>CUN</ArrivalAirport> <FlightPathCode>D</FlightPathCode> <DepartureTime>09:05</DepartureTime> <ArrivalTime>11:20</ArrivalTime> <Classes> <SellingClass> <ClassCode>X</ClassCode> <SeatCount>19</SeatCount> <FareCode>XAAA</FareCode> <FareValue>200.00</FareValue> <TaxValue>44.30</TaxValue> <RefundableFlag>0</RefundableFlag> <FloatingFareFlag>0</FloatingFareFlag> <FloatingBaseClass/> <Cabin>Z</Cabin> </SellingClass> <SellingClass> <ClassCode>T</ClassCode> <SeatCount>99</SeatCount> <FareCode>TVA</FareCode> <FareValue>210.00</FareValue> <TaxValue>584.10</TaxValue> <RefundableFlag>0</RefundableFlag> <FloatingFareFlag>0</FloatingFareFlag> <FloatingBaseClass/> <Cabin>Z</Cabin> </SellingClass> </Classes> <CodeShare/> </FlightSegment> </OriginDestinationOption> <OriginDestinationOption> <FlightSegment> <ReturnCode>0</ReturnCode> <ODNo>3</ODNo> <SegmentNo>1</SegmentNo> <CityPairNo>62</CityPairNo> <DepartureCity>MEX</DepartureCity> <ArrivalCity>CUN</ArrivalCity> <FlightNumber>AAA3144</FlightNumber> <BoardDate>2014-07-26</BoardDate> <DepartureAirport>MEX</DepartureAirport> <ArrivalAirport>CUN</ArrivalAirport> <FlightPathCode>D</FlightPathCode> <DepartureTime>21:50</DepartureTime> <ArrivalTime>00:05</ArrivalTime> <Classes> <SellingClass> <ClassCode>X</ClassCode> <SeatCount>36</SeatCount> <FareCode>XAAA</FareCode> <FareValue>300.00</FareValue> <TaxValue>44.30</TaxValue> <RefundableFlag>0</RefundableFlag> <FloatingFareFlag>0</FloatingFareFlag> <FloatingBaseClass/> <Cabin>Z</Cabin> </SellingClass> <SellingClass> <ClassCode>W</ClassCode> <SeatCount>0</SeatCount> <FareCode>WWW</FareCode> <FareValue>1000.00</FareValue> <TaxValue>193.15</TaxValue> <RefundableFlag>0</RefundableFlag> <FloatingFareFlag>0</FloatingFareFlag> <FloatingBaseClass/> <Cabin>Z</Cabin> </SellingClass> </Classes> <CodeShare/> </FlightSegment> </OriginDestinationOption> </OriginDestinationOptions>
MEX CUN AAA3140
T TVA 100.00
S STA 110.00
MEX CUN AAA3142
X XAAA 200.00
T TVA 210.00
MEX CUN AAA3144
X XAAA 300.00
W WWW 1000.00
este es el código que estoy usando pero no me da los resultados esperados
Código:
Resultado del codigo:nodelist = parser.selectNodes("soap:Envelope/soap:Body/RRT:AVAILABILITYReply/OriginDestinationOptions/OriginDestinationOption/FlightSegment") If Not nodelist Is Nothing Then Dim node1, node2 As MSXML2.IXMLDOMNode Dim damo, farerid, test As String ' For Each node1 In nodelist damo = node1.selectSingleNode("ODNo").text farerid = node1.selectSingleNode("DepartureCity").text test = node1.selectSingleNode("Classes/SellingClass/ClassCode").text ' fso.WriteLine("<FlightSegment>") fso.WriteLine("<ODNo>" & damo & "</ODNo>") fso.WriteLine("<DepartureCity>" & farerid & "</DepartureCity>") fso.WriteLine("<CC>" & test & "</CC>") fso.WriteLine("<Classes>") ' For Each node2 In nodelist Dim damo1, farerid1 As String damo1 = node2.selectSingleNode("Classes/SellingClass/ClassCode").text farerid1 = node2.selectSingleNode("Classes/SellingClass/FareValue").text fso.WriteLine("<SellingClass>") fso.WriteLine("<ClassCode>" & damo1 & "</ClassCode>") fso.WriteLine("<FareValue>" & farerid1 & "</FareValue>") fso.WriteLine("<numfl>" & damo & "</numfl>") fso.WriteLine("</SellingClass>") Next node2 fso.WriteLine("</Classes>") fso.WriteLine("</FlightSegment>") Next node1 fso.WriteLine("</FareCodes>") End If
Código:
por su atención y ayuda muchas gracias <FlightSegment> <ODNo>1</ODNo> <DepartureCity>MEX</DepartureCity> <CC>T</CC> <Classes> <SellingClass> <ClassCode>T</ClassCode> <FareValue>100.00</FareValue> <numfl>1</numfl> </SellingClass> <SellingClass> <ClassCode>X</ClassCode> <FareValue>200.00</FareValue> <numfl>1</numfl> </SellingClass> <SellingClass> <ClassCode>X</ClassCode> <FareValue>300.00</FareValue> <numfl>1</numfl> </SellingClass> </Classes> </FlightSegment> <FlightSegment> <ODNo>2</ODNo> <DepartureCity>MEX</DepartureCity> <CC>X</CC> <Classes> <SellingClass> <ClassCode>T</ClassCode> <FareValue>100.00</FareValue> <numfl>2</numfl> </SellingClass> <SellingClass> <ClassCode>X</ClassCode> <FareValue>200.00</FareValue> <numfl>2</numfl> </SellingClass> <SellingClass> <ClassCode>X</ClassCode> <FareValue>300.00</FareValue> <numfl>2</numfl> </SellingClass> </Classes> </FlightSegment> <FlightSegment> <ODNo>3</ODNo> <DepartureCity>MEX</DepartureCity> <CC>X</CC> <Classes> <SellingClass> <ClassCode>T</ClassCode> <FareValue>100.00</FareValue> <numfl>3</numfl> </SellingClass> <SellingClass> <ClassCode>X</ClassCode> <FareValue>200.00</FareValue> <numfl>3</numfl> </SellingClass> <SellingClass> <ClassCode>X</ClassCode> <FareValue>300.00</FareValue> <numfl>3</numfl> </SellingClass> </Classes> </FlightSegment>