Submitted by cogden on Wed, 2006-10-04 21:29 in Magic Parser
Any chance that magicparser supports passing in one or more attribute criteria to limit what records to extract/return from an XML file (ie, recs created this month and/or for a given location)?
All of the selective processing must be done within the record handler function. For example, if you had wanted to limit your application to processing records specific to a particular location; and that location was held within an entry called "LOCATION" in the record array (as passed to your record handler function); then something like the following would work:
<?php function myRecordHandler($record) { // ignore this record (just return) if LOCATION is not "London"; if ($record["LOCATION"] <> "London") return; // ... process record as normal ... } MagicParser_parse("data.xml","myRecordHandler"); ?>
Hi,
All of the selective processing must be done within the record handler function. For example, if you had wanted to limit your application to processing records specific to a particular location; and that location was held within an entry called "LOCATION" in the record array (as passed to your record handler function); then something like the following would work:
<?php
function myRecordHandler($record)
{
// ignore this record (just return) if LOCATION is not "London";
if ($record["LOCATION"] <> "London") return;
// ... process record as normal ...
}
MagicParser_parse("data.xml","myRecordHandler");
?>
Cheers,
David.