Darren Burgess
Darren Burgess

Reputation: 4322

error in loading url in simplexml_load_file

I have an rss feed which i would like to read from in my page, i have a local copy of the feed which reads fine but i am required to use the online version. From what i can see i am doing this correctly:

        $url ='http//www.numyspace.co.uk/~cgel1/holidays/holidays.xml';
        $holidayDoc = simplexml_load_file($url);

However i am met with the following error:

Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http//www.numyspace.co.uk/~cgel1/holidays/holidays.xml"

Why is this not working?

Upvotes: 0

Views: 857

Answers (1)

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100195

$use_errors = libxml_use_internal_errors(true);
$xml = simplexml_load_file("http://www.numyspace.co.uk/~cgel1/holidays/holidays.xml");
if (!$xml) {
  //throw new Exception("Cannot load xml source.\n");
}
libxml_clear_errors();
libxml_use_internal_errors($use_errors);

You missed a colon

Upvotes: 1

Related Questions