Extending Element class in a dom tree?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);


Regards /Erik

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux