You are here:  » Is this a bug with magic parser?


Is this a bug with magic parser?

Submitted by pard on Fri, 2009-10-16 18:35 in

I am trying to parse several elements out of the following xml

{code saved}

But there is one in particular <FARMS> that is making MP choke. When I say choke I mean that after parsing through it it breaks and it wont even display the rest of the html in the page. Well after messing with it for a while I just moved the <FARMS> element to a different location in the file, the parser works fine... this is crazy.

the following is the modified file with the <FARMS> element moved to a different location.

Anybody has any idea of why is this happening??

P Ard

Submitted by support on Fri, 2009-10-16 19:14

Hi,

You need to make sure that the correct Format String is being used when parsing specific records from an XML feed that contains multiple repeating records.

In the case of the FARM elements in your feed, the Format String required is

xml|HAND.DBTREEIMPORTFILE/FARMS/FARM/

...so an example script, to display the first record and then stop (with the XML in your URL saved to the local file farms.xml) would be as follows;

<?php
  
require("MagicParser.php");
  function 
myRecordHandler($record)
  {
    
print_r($record);
    return 
TRUE;
  }
  
MagicParser_parse("farms.xml","myRecordHandler","xml|HAND.DBTREEIMPORTFILE/FARMS/FARM/");
?>

Of course you can use your URL in place of farms.xml in the example code; and once your application is processing each record correctly removing return TRUE; from the end of the myRecordHandler function will allow the script to process all records...

Hope this helps!
Cheers,
David.