【发布时间】:2016-05-20 14:14:48
【问题描述】:
我有如下所示的 SOAP XML 响应,请建议我如何从中找到房间代码、酒店代码、货币等数据。 我也使用了下面的代码,但它不工作意味着它返回空。
$xmlObject = simplexml_load_string($xmlString);
$array = json_decode(json_encode($xmlObject), true);
对应的 XML 响应:
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<ResponseId xmlns="http://www.example.com/">e96c9439-6049-4abb-b070-f7f0024153b7@52-20-187-176</ResponseId>
</soap:Header>
<soap:Body>
<ns4:FetchRoomAllotmentResponse xmlns:ns4="http://www.example.com/" xmlns:ns2="http://www.example.com" xmlns:ns3="http://www.example.com/">
<ns4:FetchRoomAllotmentResult>
<ns4:Response>
<ns4:Hotel Code="201511191642109768" Name="TestCMHotel" />
<ns4:Rooms>
<ns4:Room Code="171578" Name="2 Bed Super Deluxe">
<ns4:Rates>
<ns4:Rate Currency="INR" Description="2 Bed Super Deluxe" Id="71624608833328" MealPlan="MAP" ValidFrom="2015-11-19" ValidTo="2017-04-30">
<ns4:Inclusions>
<ns4:Inclusion code="test inclusion test inclusion test inclusion test inclusion test inclusion">test inclusion test inclusion test inclusion test inclusion test inclusion</ns4:Inclusion>
</ns4:Inclusions>
</ns4:Rate>
</ns4:Rates>
</ns4:Room>
<ns4:Room Code="19505" Name="AC Deluxe Room AC">
<ns4:Rates>
<ns4:Rate Currency="INR" Description="AC Deluxe Room AC" Id="5835231260301" MealPlan="EP" ValidFrom="2015-11-19" ValidTo="2017-05-31">
<ns4:Inclusions>
<ns4:Inclusion code="test 1">test 1</ns4:Inclusion>
<ns4:Inclusion code="test inclusion test inclusion test inclusion test inclusion test inclusion">test inclusion test inclusion test inclusion test inclusion test inclusion</ns4:Inclusion>
</ns4:Inclusions>
</ns4:Rate>
</ns4:Rates>
</ns4:Room>
<ns4:Room Code="18303" Name="Standar AC">
<ns4:Rates>
<ns4:Rate Currency="INR" Description="Standar AC" Id="79045408874412" MealPlan="CP" ValidFrom="2015-11-19" ValidTo="2017-06-30">
<ns4:Inclusions>
<ns4:Inclusion code="test wifi and swiimming pool on a stay og one night or multiple nights 1 night or multiple nights te">test wifi and swiimming pool on a stay og one night or multiple nights 1 night or multiple nights te</ns4:Inclusion>
</ns4:Inclusions>
</ns4:Rate>
</ns4:Rates>
</ns4:Room>
</ns4:Rooms>
</ns4:Response>
</ns4:FetchRoomAllotmentResult>
</ns4:FetchRoomAllotmentResponse>
</soap:Body>
</soap:Envelope>
【问题讨论】:
标签: php xml web-services soap