XML_Parser code
| From: | Alex Rozhik | Date: | Wed, 21 Feb 2001 14:33:20 +0000 |
| Subject: | XML_Parser code | ||
| Groups: | php.pear | ||
| Request: | Send a blank email to php-pear+get-1403@lists.php.net to get a copy of this message | ||
When i try tu use XML_Parser i found some inconvenient.
Because calback functions working as static function. (I cant use $this in
it ).
I'd like to do this function as class member.
This is modified code of XML/Parser.php (see attachment)
Callback functions of new class can be used like this.
class XML_FactoryImport extends XML_NParser {
var $root;
function XML_FactoryImport( &$root, $charset='UTF-8' ) {
$this->XML_NParser( $charset );
$this->root=$root;
}
function startHandler( $p, $name, $attr) {
$this->root = $this->root->MakeChild( $name, $attr );
}
function endHandler( $p, $name ) {
$this->root = $this->root->GetParent();
}
function cdataHandler( $p, $data ) {
$this->root->SetText( $this->root->GetText().$data );
}
};
Attachment: [application/octet-stream] NParser.php
Attachment: [application/octet-stream] NParser.php