PHP5/DOM: XPath Implementation
[email protected] (Vivian Steller) Thu, 30 Sep 2004 21:08:24 +0200
| Newsgroups | php.xml.dev |
|---|---|
| Organization | eecoo |
| Message-ID | <[email protected]> |
i've a question about XPath processing in PHP5 with the new DOM
implementation:
ok, this is the introducing, simple script:
<?php
class MyElem extends DOMElement {
...
function getChildNodes() {
print("MyElem Func");
...
}
}
class MyDoc extends DOMDocument {
...
function createElement(...) {
return new MyElem(...);
}
...
}
$doc = new MyDoc();
$xp = new DOMXPath($doc);
$xp->query("/child/*[@attr = '']");
...
?>
Short summary of the script:
- extend DOMElement, DOMDocument by own classes, we want to have our own
methods like MyElem::getChildNodes() and MyElem::getAttribute().
- instanciate new doc and initialise an xpath-object for it
- execute an xpath and later on process the result...
now my question:
am i right that the xpath processor won't use the MyElem::getChildNodes() or
MyElem::getAttribute() to get the right nodes for the result? i think the
processor would choose the internal libxml function to traverse through the
dom tree. thus, seems to me that all dom (C) functions are statically bound
and not dynamically at runtime like methods of dynamically built php
objects. otherwise the output of the MyElem::getChildNodes() func in the
expample above would be "MyElem Func"?
So, once again: please enlighten me...
Thanks,
vivi