- var_dump: documentation ( source)
- json_decode: documentation ( source)
- str_replace: documentation ( source)
- preg_replace: documentation ( source)
- json_encode: documentation ( source)
<?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));