Using SimpleXML to load remote URL
Solution 1:
The results are coming back as json. Replace simplexml_load_file
with json_decode
and you will see a proper object.
If you want to use xml, you need to specify it in the headers. The following code will return valid xml:
$context = stream_context_create(array('http' => array('header' => 'Accept: application/xml')));
$url = 'http://api.ean.com/ean-services/rs/hotel/v3/list?cid=55505&minorRev=12&apiKey=2hkhej72gxyas3ky6hhjtsga&locale=en_US¤cyCode=USD&customerIpAddress=10.184.2.9&customerSessionId=&xml=<HotelListRequest><arrivalDate>01/22/2012</arrivalDate><departureDate>01/24/2012</departureDate><RoomGroup><Room><numberOfAdults>1</numberOfAdults><numberOfChildren>1</numberOfChildren><childAges>4</childAges></Room></RoomGroup><city>Amsterdam</city><countryCode>NL</countryCode><supplierCacheTolerance>MED</supplierCacheTolerance></HotelListRequest> ';
$xml = file_get_contents($url, false, $context);
$xml = simplexml_load_string($xml);
print_r($xml);
?>