@ 2017-04-25T12:06:15Z <?php
$xml = '
<?xml version="1.0" encoding="UTF-8" ?>
<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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.opentravel.org/OTA/2003/05 OTA_HotelResNotifRQ.xsd" TimeStamp="2017-04-25T13:54:59+02:00" Version="1.003" EchoToken="58ff3910062c0">
<Success />
<HotelReservations>
<HotelReservation>
<UniqueID Type="14" ID="24671-CH108B541" />
<ResGlobalInfo>
<HotelReservationIDs>
<HotelReservationID ResID_Type="14" ResID_Value="24671-CH108B541" />
</HotelReservationIDs>
</ResGlobalInfo>
</HotelReservation>
</HotelReservations>
</OTA_HotelResNotifRS>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
';
function parseReservationResponseXML($content)
{
$content = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $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);
try {
$xml = new \SimpleXMLElement($requestParams);
} catch (\Exception $e) {
$xml = null;
}
$body = (!is_null($xml) && !empty($xml->xpath('//SOAP-ENV:Body')[0])) ? $xml->xpath('//SOAP-ENV:Body')[0] : [];
return json_decode(json_encode((array)$body), true);
}
function getProviderReferenceCode($response)
{
$response = parseReservationResponseXML($response);
if (!empty($response['OTA_HotelResNotifRS']) && !array_key_exists('Success', $response['OTA_HotelResNotifRS'])) {
return false;
}
$providerReferenceCode = (isset($response['OTA_HotelResNotifRS']['HotelReservations']['HotelReservation']['ResGlobalInfo']['HotelReservationIDs']['HotelReservationID']['@attributes']['ResID_Value']))
? $response['OTA_HotelResNotifRS']['HotelReservations']['HotelReservation']['ResGlobalInfo']['HotelReservationIDs']['HotelReservationID']['@attributes']['ResID_Value']
: false;
if (!$providerReferenceCode) {
return false;
}
return $providerReferenceCode;
}
var_dump(getProviderReferenceCode($xml));
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
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.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.30 , 8.2.0 - 8.2.25 , 8.3.0 - 8.3.13 Warning: SimpleXMLElement::__construct(): Entity: line 2: parser error : XML declaration allowed only at the start of the document in /in/qen88 on line 35
Warning: SimpleXMLElement::__construct(): <?xml version="1.0" encoding="UTF-8" ?> in /in/qen88 on line 35
Warning: SimpleXMLElement::__construct(): ^ in /in/qen88 on line 35
Warning: SimpleXMLElement::__construct(): namespace error : xmlns:xsd: 'http://www.opentravel.org/OTA/2003/05 OTA_HotelResNotifRQ.xsd' is not a valid URI in /in/qen88 on line 35
Warning: SimpleXMLElement::__construct(): tance" xmlns:xsd="http://www.opentravel.org/OTA/2003/05 OTA_HotelResNotifRQ.xsd" in /in/qen88 on line 35
Warning: SimpleXMLElement::__construct(): ^ in /in/qen88 on line 35
bool(false)
preferences:dark mode live preview
87.18 ms | 410 KiB | 5 Q