Re: [PHP4BETA] cvs: /php4/ext/xml php_xml.h xml.c
| From: | Thies C. Arntzen | Date: | Mon, 06 Dec 1999 14:22:11 +0000 |
| Subject: | Re: [PHP4BETA] cvs: /php4/ext/xml php_xml.h xml.c | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-7513@lists.php.net to get a copy of this message | ||
On Mon, 6 Dec 1999, Andrei Zmievski wrote:
> On Sun, 05 Dec 1999, Thies C . Arntzen wrote:
> > thies Sun Dec 5 11:44:12 1999 EDT
> >
> > Modified files:
> > /php4/ext/xml php_xml.h xml.c
> > Log:
> > @- added XML_Set_Object() function, now you can use the XML-Parser from
> > @ within an object. (Thies)
> > (XML_Set_Object) new function.
>
> Thies,
>
> Does this mean that if there is a function called "foo" and you set an
> object that has method "foo", then it's the method that's going to get
> called not the global function?
yep -
sample:
<?
class xml {
var $parser;
function xml()
{ $this->parser = xml_parser_create();
xml_set_object($this->parser,&$this);
xml_set_element_handler($this->parser,"tag_open","tag_close");
xml_set_character_data_handler($this->parser,"cdata");
}
function parse($data)
{ xml_parse($this->parser,$data);
}
function tag_open($parser,$tag,$attributes) { var_dump($parser,$tag,$attributes); }
function cdata($parser,$cdata) { var_dump($parser,$cdata); }
function tag_close($parser,$tag) { var_dump($parser,$tag); }
}
$xml_parser = new xml();
$xml_parser->parse("<A ID=\"hallo\"> a </A>");
?>
anything wrong with this? we could set the object handler-by-handler. but
i think my approach is "nicer".
tc
>
> -Andrei
> * If it ain't broken, it doesn't have enough features yet. *
>
>
Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!"
Digital Collections Phone +49 40 235350 Fax +49 40 23535180
Hammerbrookstr. 93 20097 Hamburg / Germany