Travelport API 以这种形式给出响应,如何从 soapxml 解析这些数据,因为它正在使用命名空间。Travelport API 以这种形式给出响应。如何使用命名空间从 soapxml 解析此数据。?
<?xml version="1.0"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<air:AvailabilitySearchRsp
xmlns:air="http://www.travelport.com/schema/air_v29_0"
xmlns:common_v29_0="http://www.travelport.com/schema/common_v29_0"
TraceId="trace" TransactionId="5EF374190A076478623DB8BB3DCEE30E"
ResponseTime="801" DistanceUnits="MI">
<air:FlightDetailsList>
<air:FlightDetails Key="V7EqB14R2BKADHj4FAAAAA==" Origin="LGW"
Destination="EDI" DepartureTime="2017-07-30T19:15:00.000+01:00"
ArrivalTime="2017-07-30T20:45:00.000+01:00" FlightTime="90"
TravelTime="90" OriginTerminal="North Terminal"/>
<air:FlightDetails Key="V7EqB14R2BKAGHj4FAAAAA==" Origin="LGW"
Destination="EDI" DepartureTime="2017-07-30T20:55:00.000+01:00"
ArrivalTime="2017-07-30T22:25:00.000+01:00" FlightTime="90"
TravelTime="90" OriginTerminal="North Terminal"/>
<air:FlightDetails Key="V7EqB14R2BKAJHj4FAAAAA==" Origin="LGW"
Destination="EDI" DepartureTime="2017-07-30T13:35:00.000+01:00"
ArrivalTime="2017-07-30T15:10:00.000+01:00" FlightTime="95"
TravelTime="95" OriginTerminal="North Terminal"/>
<air:FlightDetails Key="V7EqB14R2BKAMHj4FAAAAA==" Origin="LGW"
Destination="EDI" DepartureTime="2017-07-30T15:50:00.000+01:00"
ArrivalTime="2017-07-30T17:25:00.000+01:00" FlightTime="95"
TravelTime="95" OriginTerminal="North Terminal"/>
</air:FlightDetailsList>
</air:AvailabilitySearchRsp>
</SOAP:Body>
</SOAP:Envelope>
嗨,您可以使用库将 xml 转换为数组。下面是一个这样的库 URL。 http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array/
它会将您 xml 转换为以下数组格式。您可以轻松解析。
数组 ( [肥皂:信封] => 数组 ( [肥皂:身体] => 数组 ( [空气:可用性搜索Rsp] =>数组 ( [空气:航班详情列表] => 数组 ( [空气:航班详情] => 数组 ( [0] => 数组 ( [@value] => [@attributes] => 数组 ( [键] => V7EqB14R2BKADHj4FAAAAA== [起源] => 友好社 [目的地] => 电子数据交换 [出发时间] => 2017-07-30T19:15:00.000+01:00 [到达时间] => 2017-07-30T20:45:00.000+01:00 [飞行时间] => 90 [旅行时间] => 90 [始发地航站楼] =>北航站楼 )
)
[1] => Array
(
[@value] =>
[@attributes] => Array
(
[Key] => V7EqB14R2BKAGHj4FAAAAA==
[Origin] => LGW
[Destination] => EDI
[DepartureTime] => 2017-07-30T20:55:00.000+01:00
[ArrivalTime] => 2017-07-30T22:25:00.000+01:00
[FlightTime] => 90
[TravelTime] => 90
[OriginTerminal] => North Terminal
)
)
[2] => Array
(
[@value] =>
[@attributes] => Array
(
[Key] => V7EqB14R2BKAJHj4FAAAAA==
[Origin] => LGW
[Destination] => EDI
[DepartureTime] => 2017-07-30T13:35:00.000+01:00
[ArrivalTime] => 2017-07-30T15:10:00.000+01:00
[FlightTime] => 95
[TravelTime] => 95
[OriginTerminal] => North Terminal
)
)
[3] => Array
(
[@value] =>
[@attributes] => Array
(
[Key] => V7EqB14R2BKAMHj4FAAAAA==
[Origin] => LGW
[Destination] => EDI
[DepartureTime] => 2017-07-30T15:50:00.000+01:00
[ArrivalTime] => 2017-07-30T17:25:00.000+01:00
[FlightTime] => 95
[TravelTime] => 95
[OriginTerminal] => North Terminal
)
)
)
)
[@attributes] => Array
(
[TraceId] => trace
[TransactionId] => 5EF374190A076478623DB8BB3DCEE30E
[ResponseTime] => 801
[DistanceUnits] => MI
)
)
)
)
(