You are here:  » Access Parser inside class


Access Parser inside class

Submitted by cybersys on Tue, 2007-09-11 11:25 in

Can i access the parser inside a class

using : MagicParser_parse("string://".$xml_string,"CreateArray","xml|NODES/");

i get the message that CreateArray function does not exit

if i try $this->CreateArray i get an error from magicparser

Is there any solution

Submitted by support on Tue, 2007-09-11 11:33

Hi,

Whilst you can use the parser call within a class, your record handler will have to be outside of the class container. What I would recommend is that rather than trying to access the class through the record handler function, setup a global variable to hold the array that you are trying to create, and then copy it into the class after the call; for example:

  $GlobalNodes = array();
  MagicParser_parse("string://".$xml_string,"CreateArray","xml|NODES/");
  $this->nodes = $GlobalNodes;

Within your CreateArray record handler function (which must be external to the class), start with:

  global $GlobalNodes;

Hope this helps,
Cheers,
David.