I've recently extended DOMDocument using Zend_Dom's components to help. I've added some features. However, for those familiar with prototype, they have some functions -- down being perhaps the most important for me at this stage.
I'm wanting to add a feature to DOMDocument whereby I have a node in the node tree, and from that node I want to be able to query as in Prototype's down function.
Now, Zend Framework's extension of DOMDocument allows you to pass a CSS or XPath query. However, the feature that it's missing is the ability to specify the node to select in. So if I pass in the current node as the DIV, then it'll execute the query based on that element and all its children, but not the entire document.
I am not sure how to do this. I could construct the CSS selector query myself by back-tracking through the tree node and finding parent after parent, but this seems like a terribly inefficient way of going about this task.
Does anybody have any idea? I even tried to get the textContent member variable and set it as the HTML document, but this doesn't appear to help me.
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
The Following User Says Thank You to Wildhoney For This Useful Post:
CSS-style selectors get translated to XPath under-the-hood. Wherever Zend's wrapper makes the call through to DOMXPath::query, you'll have to provide a context node as the second argument. Or, that's one way at least.
The Following 2 Users Say Thank You to Salathe For This Useful Post: