-1
SimpleXMLElement Object
(
[FlightOption] => Array
(
[0] => SimpleXMLElement Object
(
[Flight] => SimpleXMLElement Object
(
[@attributes] => Array
(
[ArrivalDateTime] => 2014-07-05T15:00:00.000
[DepartureDateTime] => 2014-07-05T13:00:00.000
[EquipmentCode] => 321
[FlightNumber] => 677
)
[Airline] => SimpleXMLElement Object
(
[@attributes] => Array
(
[AirlineCode] => AI
[IATACode] => AI
[ICAOCode] => AIC
[Name] => Air India
)
)
[ArrivalAirport] => SimpleXMLElement Object
(
[@attributes] => Array
(
[AirportCode] => DEL
[IATACode] => DEL
[ICAOCode] => VIDP
[Name] => Indira Gandhi International Airport
)
)
[Cabin] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Code] => C
[Name] => Coach
)
[FareClass] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Code] => Y
[Name] => ECONOMY
[NumOfAvailableSeats] => 9
)
)
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Code] => B
[Name] => Business
)
[FareClass] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Code] => C
[Name] => BUSINESS
[NumOfAvailableSeats] => 4
)
)
)
)
)
)
)
)
)
我必須解析上面的xml響應。請幫助我。通過php解析xml響應
我正在使用下面的代碼,但它使我錯誤代碼,並沒有獲得變量中的所有值。
foreach ($data->FlightOption as $FlightOption) {
printf(
$FlightOption["Flight"]->ArrivalDateTime
/*$FlightOption->FareClass,
$FlightOption->Airline*/
);
}