Page 1 of 1

simplexml_load_file() can not find file at URL

Posted: Tue Jan 29, 2008 4:10 am
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

Re: simplexml_load_file() can not find file at URL

Posted: Tue Jan 29, 2008 4:24 am
by edzillion
I've fixed it. thanks.
The hosting service had turned off outbound connections by default.