Can I use simplexml_load_file ($ url) without automatically exiting $ url?

I am trying to use simplexml_load_file ($ url) with

$url = "http://www.example.com/dir/file.php?id=test&output=xml";

Now, unfortunately, simplexml_load_file () automatically preempts all ampersands and replaces them with "& amp;" s, which in turn interrupts file.php because, for some strange reason, it cannot process "& amp;" but only ordinary ampersands.

Is it possible to somehow download the file without escaping the url so that I keep my normal one instead of & & s?

Thank!

+3
source share
3 answers

The right way:

$xml = simple_xml_load_file(file_get_contents("http://www.example.com/dir/file.php?id=test&output=xml"));

Edit:

I tried the following code:

$xml = new SimpleXMLElement(file_get_contents('http://www.example.com/dir/file.php?id=test&output=xml'));

XML API. . html special char .

+1
0

I found this to work:

$xml = simplexml_load_string( file_get_contents( 'http://my.url.com' ) );
0
source

All Articles