Re: Extending Element class in a dom tree?

From: Date: Sat, 30 Apr 2005 21:40:03 +0000
Subject: Re: Extending Element class in a dom tree?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-214274@lists.php.net to get a copy of this message
On 4/30/05, Erik Franzén <erik@nordicaudi.com> wrote: > The DOM implementation i PHP5 allows classes to be extended. Extending > the Document class is no problem, but how can I extend the Element class > and use it in a DOM tree? > > DOMDocument::createElement returns a DOMElement object which you cannot > extend. > > Could this be a solution? > > class MyElement extends DomElement { > function __construct($a_stTagName) { > //has to be called! > parent::__construct($a_stTagName); > } > > function myFunction() { > // do something > } > } > > $oDom = new DomDocument(); > $oMyElement = new MyElement('mytag'); > > $oMyElement = $oDom->importNode($oMyElement, true); > $oMyElement = $oDom->appendChild($oMyElement); Does not work, will never work, just forget about it ;) chregu > > Regards > /Erik > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | chregu@bitflux.ch | gnupg-keyid 0x5CE1DECB

« previous php.general (#214274) next »