simplexml_load_file() can not find file at URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
edzillion
Forum Newbie
Posts: 12
Joined: Mon Jan 28, 2008 10:06 am

simplexml_load_file() can not find file at URL

Post by edzillion »

I'm trying to load an xml file from a URL. For a test I copied the code from the php manual here: http://ie.php.net/simplexml_load_file

Code: Select all

<?php
// The file test.xml contains an XML document with a root element
// and at least an element /[root]/title.
 
// New York Times RSS feed
$sourcePath = "http://partners.userland.com/nytRss/nytHomepage.xml"
 
if (file_exists($sourcePath)) {
    $xml = simplexml_load_file($sourcePath);
 
    print_r($xml);
} else {
    exit('Failed to open test.xml.');
}
?>
 
I can browse to the URL and I see an XML file. Also if I save the xml file from the URL into the same folder as the php, then the script finds the file and print_r($xml); displays its contents.

Can anyone help me?
TIA
Ed
edzillion
Forum Newbie
Posts: 12
Joined: Mon Jan 28, 2008 10:06 am

Re: simplexml_load_file() can not find file at URL

Post by edzillion »

I've fixed it. thanks.
The hosting service had turned off outbound connections by default.
Post Reply