I am trying to extend the DOMDocument class to make XPath easier to select. I wrote this piece of code:
class myDOMDocument extends DOMDocument { function selectNodes($xpath){ $oxpath = new DOMXPath($this); return $oxpath->query($xpath); } function selectSingleNode($xpath){ return $this->selectNodes($xpath)->item(0); } }
These methods return a DOMNodeList and a DOMNode, respectively. Now I would like to implement similar methods for DOMNode objects. But, obviously, if I write a class (myDOMNode) that extends DOMNode, I cannot use these two additional methods on the nodes returned by myDOMDocument, because they are DOMNode objects (not myDOMNode).
I am more likely to be new to programming objects, I have tried different ideas, but they all lead to a dead end.
Any clues? Thank you very much in advance.
source share