simplexml_load_file() can not find file at URL
Posted: Tue Jan 29, 2008 4:10 am
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
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
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.');
}
?>
Can anyone help me?
TIA
Ed