View Single Post
Old 07-27-2009, 08:39 PM   #1 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Plugin/Addon Extending DOMDocument with Zend Framework

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.

Ideally it would be like so:

php Code:
$pNode = $pCurrentNode->firstChild->query('div img.myImage');

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.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
codefreek (07-28-2009)