note 109301 added to class.domnodelist
| From: | ignitedfirestarter at gmail dot com | Date: | Wed, 04 Jul 2012 10:39:52 +0000 |
| Subject: | note 109301 added to class.domnodelist | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-189025@lists.php.net to get a copy of this message | ||
If you want to recurse over a DOM then this might help:
<?php
/**
* PHP's DOM classes are recursive but don't provide an implementation of
* RecursiveIterator. This class provides a RecursiveIterator for looping over DOMNodeList
*/
class DOMNodeRecursiveIterator extends ArrayIterator implements RecursiveIterator {
public function __construct (DOMNodeList $node_list) {
$nodes = array();
foreach($node_list as $node) {
$nodes[] = $node;
}
parent::__construct($nodes);
}
public function getRecursiveIterator(){
return new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST);
}
public function hasChildren () {
return $this->current()->hasChildNodes();
}
public function getChildren () {
return new self($this->current()->childNodes);
}
}
?>
----
Server IP: 94.76.225.145
Probable Submitter: 88.98.44.237
----
Manual Page -- http://www.php.net/manual/en/class.domnodelist.php
Edit -- https://master.php.net/note/edit/109301
Del: integrated -- https://master.php.net/note/delete/109301/integrated
Del: useless -- https://master.php.net/note/delete/109301/useless
Del: bad code -- https://master.php.net/note/delete/109301/bad+code
Del: spam -- https://master.php.net/note/delete/109301/spam
Del: non-english -- https://master.php.net/note/delete/109301/non-english
Del: in docs -- https://master.php.net/note/delete/109301/in+docs
Del: other reasons-- https://master.php.net/note/delete/109301
Reject -- https://master.php.net/note/reject/109301
Search -- https://master.php.net/manage/user-notes.php