Invalid XML Characters accessing URL



I am using a PHP script that reads in an xml file, assigns it to a variable, and then converts it to a PHP array. When I access the xml's URL using the following code, I get Invalid Character Errors:



<?php
$handle = fopen($url, "r");

if($handle){
while(!feof($handle)){
$xml = fgets($handle, 4096);

}
fclose($handle);
}
// OR
$xml = simplexml_load_file($url);
?>


However, if I copy and paste the xml output and assign it to a variable directly in the script, it correctly converts the xml data to a PHP array.


Here's the xml url



<?php
$url = "http://ift.tt/10LNSqx";
?>


I need it to work by pulling the xml directly from the URL. Any ideas?


No comments:

Post a Comment