3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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));
based on s83fY
Output for 5.6.0 - 7.2.6
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." } } }