TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-27-2009, 08:39 PM   #1 (permalink)
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)
Old 07-27-2009, 08:51 PM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

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.
Salathe is offline  
Reply With Quote
The Following 2 Users Say Thank You to Salathe For This Useful Post:
codefreek (07-28-2009), Wildhoney (07-27-2009)
Old 07-27-2009, 08:59 PM   #3 (permalink)
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
Default

That's perfect ! I knew I was right to ask.
__________________
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
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Zend Framework Tanax General 21 03-23-2009 07:07 PM
Zend Studio code completion framework Devels General 1 09-06-2008 05:04 PM
Zend Framework in Action (book) freenity The Lounge 2 04-06-2008 11:12 AM
Zend Framework 1.5 Devels Libraries & Extensions 5 03-17-2008 03:06 PM
Zend Framework - questions questions abiko Advanced PHP Programming 4 02-29-2008 12:46 AM


All times are GMT. The time now is 07:35 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design