I'm new to PHP, with little practice of OOP, and I'm trying to extend the DomDocument class (in DOM) with a method that runs an XPath selection:
class ExtDomDocument extends DomDocument { public function selectNodes($xpath) { $processor = new DOMXPath($this); return $processor->query($xpath); } } This runs fine, but it seems better to me to have the DOMXPath object instantiated in the constructor (so this is done only once and it can be used by additional methods). The following code doesn't work but I'd like to do something along those lines: class ExtDomDocument extends DomDocument { private $processor; function __construct() { parent::__construct(); $processor = new DOMXPath($this); } public function selectNodes($xpath) { $processor = new DOMXPath($this); return $processor->query($xpath); } } I'll be grateful for your help. Nicolas --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---