Re: PHP Newbie Classes / XML Question

From: Date: Fri, 22 Mar 2002 21:38:12 +0000
Subject: Re: PHP Newbie Classes / XML Question
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-81627@lists.php.net to get a copy of this message
So, as I understand this, I should do it like this??? class stdxml { function stdxml($xmlfilename) { $parser=xml_parser_create(); xml_set_element_handler($parser, array("stdxml","startElementHandler"), array("stdxml","endElementHandler"); This yields the wonderfully helpful error: Parse error: parse error in C:\Inetpub\wwwroot\PHP\stdqclass.php on line 20 I believe I am following the first syntax you listed: array('class', 'methdod'); // static "Markus Fischer" <mfischer@guru.josefine.at> wrote in message news:20020322213100.GA26875@guru.josefine.at... > the syntax for passing methods of static classes or objects > is > > array('class', 'methdod'); // static > > or > > array($object, 'method'); // without and > > array(&$object, 'method')) // by reference > > - Markus > > On Fri, Mar 22, 2002 at 04:19:42PM -0500, arti wrote : > > I am very new to PHP and have what is probably a dumb question. I am > > attempting to parse an XML document with a Class. > > > > But, you have to use "xml_set_element_handler" for this to work and that > > means you have to pass it the names of your element handlers. How do I do > > this in a class??? > > > > For example, this does not work: > > > > xml_set_element_handler($parser, "this->startElementHandler", > > "this->endElementHandler"); > > > > as I get this error: > > > > Warning: Unable to call handler this->startElementHandler() in > > C:\Inetpub\wwwroot\PHP\stdqclass.php on line 31 > > > > > > If I remove the "this->" I get the exact same error only without the > > "this->". > > > > > > I want the class to handle the XML totally on its own, but I am cannot > > figure out how to pass the xml_set_element_handler function a reference to > > my event handlers. Can this be done from within a class and if so, how do I > > pass my event handlers? > > > > Thanks, > > > > -- Brian > > > > > > > > -- > > PHP Development Mailing List <http://www.php.net/> > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > Please always Cc to me when replying to me on the lists. > GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc

« previous php.dev (#81627) next »