2

我正在处理航班预订应用程序的 SOAP 客户端响应,我成功获得了响应,请参阅下面的响应:

<arzoo__response>
<Response__Depart>
    <OriginDestinationOptions>
        <OriginDestinationOption>
            <FareDetails>
                <ChargeableFares>
                    <ActualBaseFare>4850</ActualBaseFare>
                    <Tax>4267</Tax>
                    <STax>31</STax>
                    <SCharge>0</SCharge>
                    <TDiscount>0</TDiscount>
                    <TPartnerCommission>0</TPartnerCommission>
                </ChargeableFares>
                <NonchargeableFares>
                    <TCharge>0</TCharge>
                    <TMarkup>0</TMarkup>
                    <TSdiscount>0</TSdiscount>
                </NonchargeableFares>
            </FareDetails>
            <FlightSegments>
                <FlightSegment>
                    <AirEquipType>321</AirEquipType>
                    <ArrivalAirportCode>DEL</ArrivalAirportCode>
                    <ArrivalDateTime>2013-05-20T08:00:00</ArrivalDateTime>
                    <DepartureAirportCode>BOM</DepartureAirportCode>
                    <DepartureDateTime>2013-05-20T06:00:00</DepartureDateTime>
                    <FlightNumber>601</FlightNumber>
                    <OperatingAirlineCode>AI</OperatingAirlineCode>
                    <OperatingAirlineFlightNumber>601</OperatingAirlineFlightNumber>
                    <RPH></RPH>
                    <StopQuantity>0</StopQuantity>
                    <airLineName>Air India</airLineName>
                    <airportTax>4267</airportTax>
                    <imageFileName>http://live.arzoo.com/FlightWS/image/AirIndia.gif</imageFileName>
                    <viaFlight></viaFlight>
                    <BookingClass> 
                        <Availability>4</Availability>
                        <ResBookDesigCode>U</ResBookDesigCode>
                    </BookingClass>
                    <BookingClassFare>
                        <adultFare>4850</adultFare>
                        <bookingclass>U</bookingclass>
                        <classType>Economy</classType>
                        <farebasiscode>fjyS3YyUlEusLfJ4bwgPvQ==</farebasiscode>
                        <Rule>This fare is Refundable &lt;br&gt; Baggage : 25K&lt;br&gt;Booking Class : U|Re-Schedule Charges: Rs. 750 per sector + Fare difference (If any) +admin fee 500 + Service Fee of Rs. 250 Sector .|Cancellation Charges : Basic fare +Airline administration fee 500 + Service Charges 250 Per Passenger Per Sector . |</Rule>
                        <adultCommission>0</adultCommission>
                        <childCommission>0</childCommission>
                        <commissionOnTCharge>0</commissionOnTCharge>
                    </BookingClassFare>
                    <Discount>0</Discount>
                    <airportTaxChild>0</airportTaxChild>
                    <airportTaxInfant>0</airportTaxInfant>
                    <adultTaxBreakup>2800,147,1320</adultTaxBreakup>
                    <childTaxBreakup>0,0,0</childTaxBreakup>
                    <infantTaxBreakup>0,0,0</infantTaxBreakup>
                    <octax>0</octax>
                </FlightSegment> 
            </FlightSegments>
            <id>arzoo11</id>
            <key>wtZcSVMY/gphWFSOTFWg8oKRnosq3p9wt7R4SjMB0EUK8sDjVS91GicTJzH+TWN+pNURIyTJYKOW O8yH8+0tzpA4t8aEEvzaOE6ZnTtBotFDwLtSiN0xXqMsaDl8diV51l7d9ata/3rxTgfh9d8ZSmFY VI5MVaDywdHNcjAR1vwnEycx/k1jftlsnmWWqYGnJxMnMf5NY36YIq2FtLkfcHtsd+IDEhxpxJuT v4YyS+QnEycx/k1jftlsnmWWqYGnJxMnMf5NY37ZbJ5llqmBpycTJzH+TWN+GlZsae+KA6L3dlms eLkXZFKXPvd5FAnBXnTfRGc5sz+UC8CsZNzDV2FYVI5MVaDyFiThuG7WKPhzqWDbQb1E1IqUKT5I FtF6OaCYjb6EFGhDwLtSiN0xXt7N3OmPGVH2v18OFlhFoI+A/uAfnTovYr9fDhZYRaCPgP7gH506 L2K/Xw4WWEWgj4D+4B+dOi9iv18OFlhFoI+A/uAfnTovYr9fDhZYRaCPgP7gH506L2K/Xw4WWEWg j4D+4B+dOi9iv18OFlhFoI/87KPqwdBsCm4nF4DlZwRNQ/zni8QE42g8S0GV1z3SJXaOdoTFisn9 v18OFlhFoI+ThOYsjNAbXEP854vEBONoPEtBldc90iVD/OeLxATjaAwTg0ygCEBmEgnKEhG4Md1D /OeLxATjaDxLQZXXPdIlQ/zni8QE42jXGTnbB/ydvR4daAuN34kWYVhUjkxVoPJtRWbi6bZrXL9f DhZYRaCPgP7gH506L2K/Xw4WWEWgj4D+4B+dOi9iv18OFlhFoI8KriAmVoEyR3OpYNtBvUTUp1Mf I240+obPusGaAOeuxg==</key>
        </OriginDestinationOption>
    </OriginDestinationOptions>
</Response__Depart>
</arzoo__response>

现在我必须将它们显示为:

基本价格:4850 税费:31 STax:31 SCharge:0 TDiscount:0 TPartnerCommission:0 ..... 到达机场代码:DEL ..... ......

我尝试了几种方法foreach()

   $result = $client->__call('getAvailability',array($test));   
   $xml = simplexml_load_string($result);
    foreach($xml->OriginDestinationOption as $od){
        foreach($od->FareDetails as $fd){
            foreach($fd->ChargeableFares as $cf){
                echo $cf->ActualBaseFare;
            }
        }
    }

但从来没有解决过。有人可以帮我解决这个问题吗?必须感谢您的帮助。提前致谢

4

1 回答 1

3

您正在尝试访问OriginDestinationOption,就好像它是 XML 响应的直接子级一样,但结构实际上是这样的:

<arzoo__response>
    <Response__Depart>
        <OriginDestinationOptions>
            <OriginDestinationOption>

因此,由于您$xml将代表arzoo__response元素,因此您需要遍历其间的其他元素:

foreach($xml->Response__Depart->OriginDestinationOptions->OriginDestinationOption as $od)
于 2013-05-13T12:30:45.177 回答