Was using this code successfully but it stopped working. Now, when I view the page it just has "could not open" printed. What does that error mean?
The XML file appears to be fine, you can view it at http://217.77.185.16/xml/data.xml
What is going on here? I know that the file is being read because when I change the ../XML/data.xml path to something else you get PHP errors.
<?php
include 'functions.php';
require 'MagicParser.php';
?>
<?php
$stats = array();
function myRecordHandler($record) {
global $stats;
$stats[] = $record;
}
// read XML into a string
$fp = fopen("../XML/data.xml","r");
while(!feof($fp)) $xml .= fread($fp,1024);
fclose($fp);
// remove white space
$xml = trim($xml);
// parse using temporary file API
$temp = MagicParser_createFile($xml);
$result = MagicParser_parse($temp,"myRecordHandler","xml|DATASET/STAT/");
if (!$result) {
print MagicParser_getErrorMessage();
}
?>
Hello Jay,
The normal error message is "could not open ", but since there is no filename given that would imply that $temp is empty. Tracing back through the code, it follows that the MagicParser_creatFile function was not able to generate a temporary file, and this might be because the temporary directory on your server is full.
If this is the case, you need to find out where your system's temporary directory is and empty it (once you are satisfied that another application is not dependant upon another file in there). On most Linux servers, it is /tmp. Windows server typically use c:\temp.
Cheers,
David.