note 35465 added to function.xml-set-object

From: Date: Tue, 02 Sep 2003 02:05:11 +0000
Subject: note 35465 added to function.xml-set-object
Groups: php.notes 
Request: Send a blank email to php-notes+get-55450@lists.php.net to get a copy of this message
Just a note about creating abstract "call back handlers" as mentioned in some of the other notes. In this case I recommend extending the base XML class and overwritting the handler methods. The reason I wanted to do this, is that if you have a separate callback method class it causes problems, for example if you want to collect information out of the XML file and store it in an array. You can get around it with global variables, but I prefer to use them only when required ;) Example: <?php class xml_output extends xml{ var $output = array(); function xml_output(){ $this->xml(); } //overwrite base methods function tag_open($parser, $tag, $attributes) { array_push($this->output, "<$tag, attributes>"); } function cdata($parser, $cdata) { array_push($this->output, "$cdata"); } function tag_close($parser, $tag) { array_push($this->output, "</$tag>"); } } $xml_parser = & new xml_output(); $xml_parser->parse("<A ID='hallo'>PHP</A>"); echo("$xml_parser->output"); ?> ---- Manual Page -- http://www.php.net/manual/en/function.xml-set-object.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35465 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35465&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35465&report=yes

« previous php.notes (#55450) next »