<?php
$a = "
<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
<SOAP-ENV:Body>
<OTA_HotelResNotifRS xmlns='http://www.opentravel.org/OTA/2003/05' TimeStamp='2016-12-01T07:14:56' EchoToken='f3edc6ef-8734-4c83-8675-c9462d808e62' Version='1.003' xsi:schemaLocation='http://www.opentravel.org/OTA/2003/05 OTA_HotelResNotifRQ.xsd'>
<Errors Type='3'>
<Error Type='1'>Premature end of file.</Error>
</Errors>
</OTA_HotelResNotifRS>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>";
function parseReservationResponseXML($content)
{
/*
* RateTiger response da xsi eklenince hata aldigimizdan dolayi bu bolum siliniyor.
*/
$content = str_replace("xsi:schemaLocation='http://www.opentravel.org/OTA/2003/05 OTA_HotelResNotifRQ.xsd'", '', $content);
$requestParams = preg_replace("/(<\/?)(\w+):([^>]*>)/", "$1$2$3", $content);
$xml = new SimpleXMLElement($requestParams);
$body = $xml->xpath('//SOAP-ENV:Body')[0];
return json_decode(json_encode((array)$body), true);
}
var_dump(parseReservationResponseXML($a));
- Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.16, 7.3.18 - 7.3.33, 7.4.0 - 7.4.4, 7.4.6 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.0 - 8.3.15, 8.4.1 - 8.4.2
- array(1) {
["OTA_HotelResNotifRS"]=>
array(2) {
["@attributes"]=>
array(3) {
["TimeStamp"]=>
string(19) "2016-12-01T07:14:56"
["EchoToken"]=>
string(36) "f3edc6ef-8734-4c83-8675-c9462d808e62"
["Version"]=>
string(5) "1.003"
}
["Errors"]=>
array(2) {
["@attributes"]=>
array(1) {
["Type"]=>
string(1) "3"
}
["Error"]=>
string(22) "Premature end of file."
}
}
}
- Output for 7.3.17, 7.4.5
- array(1) {
["OTA_HotelResNotifRS"]=>
array(2) {
["@attributes"]=>
array(3) {
["TimeStamp"]=>
string(19) "2016-12-01T07:14:56"
["EchoToken"]=>
string(36) "f3edc6ef-8734-4c83-8675-c9462d808e62"
["Version"]=>
string(5) "1.003"
}
["Errors"]=>
array(2) {
["@attributes"]=>
array(1) {
["Type"]=>
string(1) "3"
}
["Error"]=>
array(2) {
["@attributes"]=>
array(1) {
["Type"]=>
string(1) "1"
}
[0]=>
string(22) "Premature end of file."
}
}
}
}
preferences:
52.42 ms | 408 KiB | 5 Q