require("MagicParser.php");
function myRecordHandler($record)
{
// This is where you write your code to process each record, such as loading a database
// Here we just display the record contents using PHP's internal print_r() function
//print_r($record);
$temp_array[] = $record;
}
MagicParser_parse("test1.svg","myRecordHandler","xml|SVG/G/G/");
echo "";
print_r($temp_array);
echo "";
I try to load the entire XML into an array, but I cannot do it, please help.
Hi There,
The only error I can see there is that $temp_array is not declared as global within myRecordHandler, therefore you are not adding each item to the array. Have a go with this code:
<?php
require("MagicParser.php");
function myRecordHandler($record)
{
global $temp_array;
// This is where you write your code to process each record, such as loading a database
$temp_array[] = $record;
}
MagicParser_parse("test1.svg","myRecordHandler","xml|SVG/G/G/");
print_r($temp_array);
?>
Hope this helps!
Cheers,
David.