The most straight forward way is to set another global variable for example $gotRecords and set this to TRUE in your record handler. You can then check it after the parse to see if any records existed, and try again with another URL if not. For example:
<?php // create a global variable to indicate results and set to FALSE $gotRecords = FALSE; function myRecordHandler($record) { // set $gotRecords to TRUE because we know we have records here global $gotRecords; $gotRecords = TRUE; } // parse as usual MagicParser_parse("file.xml","myRecordHandler"); // after parsing, check if $gotRecords is still FALSE if (!$gotRecords) { // try and parse your backup URL MagicParser_parse("file2.xml","myRecordHandler"); } ?>
You can of course do the same test again after parsing the second file, and if it's still FALSE display a message for example...
Hi,
The most straight forward way is to set another global variable for example $gotRecords and set this to TRUE in your record handler. You can then check it after the parse to see if any records existed, and try again with another URL if not. For example:
<?php
// create a global variable to indicate results and set to FALSE
$gotRecords = FALSE;
function myRecordHandler($record)
{
// set $gotRecords to TRUE because we know we have records here
global $gotRecords;
$gotRecords = TRUE;
}
// parse as usual
MagicParser_parse("file.xml","myRecordHandler");
// after parsing, check if $gotRecords is still FALSE
if (!$gotRecords)
{
// try and parse your backup URL
MagicParser_parse("file2.xml","myRecordHandler");
}
?>
You can of course do the same test again after parsing the second file, and if it's still FALSE display a message for example...
Cheers,
David.