Forum Moderators: coopster
Does anybody know a function for PHP 4.3.4 that will retrieve an XML document from an external server?
$myXML = file_get_contents($price_url);
does not work and neither does
$myXMLDoc = new XMLDocument("XML URL");
$myXML = $myXMLDoc->getXML();
altough this one will work locally. Any help would be greatly appreciated. Thanks.
<?php
// include a class-loading function
require_once("activelink/classes/include.php");
// import XML and XMLDocument classes
import("org.active-link.xml.XML");
import("org.active-link.xml.XMLDocument");
$filename = "http.....(link to xml URL)";
$handle = fopen($filename, "r");
$myXMLstring = fread($handle, filesize($filename));
fclose($handle);
$myXMLDoc = new XMLDocument();
$myXMLDoc -> parseFromString($myXMLString);
$myXML = $myXMLDoc->getXML();
$priceBranchArray = $myXML->getBranches("o1:OSTKXML/o1:OSTKPRODUCT",
"o1:Price");
print("Test1");
print($priceBranchArray[0]->getTagContent());
print("Test2<br>");
?>
Error Messages=
Warning: fopen(http://...Whichever XML URL I am linking to): failed to open stream: HTTP request failed! ¦ؿ̺ @ӿ ~ on line 11
Warning: filesize(): Stat failed for [...(Whichever...] XML URL I am linking to) (errno=2 - No such file or directory) on line 12
Warning: fread(): supplied argument is not a valid stream resource on line 12
Warning: fclose(): supplied argument is not a valid stream resource on line 13
Fatal error: Call to a member function on a non-object on line 22