如何从URL获取xml数据

I am new in php programming. Actually i want to extract xml code residing on a site. Till now i used

$xml=simplexml_file_load(//URL);  
foreach($xml->movie as $Movies)  
{  
print $Movies->name;  
} 

but this code doesnt produce any value.

After that i also used

$header[] = "Accept: application/xml";  
$ch = curl_init();  
echo $ch;  
curl_setopt( $ch, CURLOPT_HTTPHEADER, $header );  
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');  
curl_setopt( $ch, CURLOPT_URL, $url );  
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );  
$contents = curl_exec ($ch);  
echo $contents;   
curl_close($ch);

But this code return only value in that xml(excluded tag).

i also used

readfile($url);  

But This code return value in json format.

Please give me the solution about how can i read that value.

Well i think JSON function work on your machine. I think so because of the error which you get. Also example from DanFromGermany should work but URL is kind of long so maybe it was cut off. Here is what you can try:

1.) Go here: https://api.eancdn.com/api/tester/ and choose from links above what you want to parse. I tried with "Hotel List". So click on link "Hotel List", choose JSON format and click proceed. Then you will see entire link bellow (it's long). Right click and copy it.

2.) This PHP code should work (it worked for me) it's just a little bit complicated structure of JSON and then ARRAY so important data is pretty DEEP :)

$url = "https://api.eancdn.com/ean-services/..."; //(ENTIRE URL HERE - its LONG)
$arr = json_decode(file_get_contents($url), true); // true is for array, false for objects

//parse data from array $arr['HotelListResponse']['HotelList']['HotelSummary']
foreach ($arr['HotelListResponse']['HotelList']['HotelSummary'] as $hotel){

$hname = $hotel['name']; //get hotel name from array
$hid = $hotel['hotelId']; //get hotel id from array
$haddress = $hotel['address1']; //get hotel address1 from array

echo "<b>Hotel name:</b> $hname Hotel ID: $hid Hotel address 1: $haddress <br>";
}

3.) There are also other data which you can get it for each hotel. Check some samples and return data here: JSON1 (return array) and here for some parsed data like hotel id, hotel address etc. - same PHP code as above - 2.)

How to get Json from the "Hotel List" example

from https://api.eancdn.com/api/tester/#query=basicAvailability

$url = 'https://api.eancdn.com/ean-services/rs/hotel/v3/list?cid=55505&minorRev=99&apiKey=cbrzfta369qwyrm9t5b8y8kf&locale=en_US&currencyCode=USD&......';
$arr = json_decode(file_get_contents($url), true); // true is for array, false for objects

print_r($arr);

This will at least help you trying to get to the right array elements. I have to admin their JSON is rather strange (with the 0: ..., 1: ...).