Location: PHPKode > scripts > tgcSPL > tgcspl/include/DomNodeListIterator.php
<?php
/**
 * DomNodeList iterator
 *
 * Allows iteration over a DomNodeList object.
 *
 * $Id: DomNodeListIterator.php,v 1.1 2004/09/24 01:25:49 luckec Exp $
 *
 * @package     tgcSPL
 * @subpackage  Iterators
 * @author      Carsten Lucke <hide@address.com>
 * @copyright   Carsten Lucke <hide@address.com>
 */
 
/**
 * DomNodeList iterator
 *
 * Allows iteration over a DomNodeList object.
 *
 * $Id: DomNodeListIterator.php,v 1.1 2004/09/24 01:25:49 luckec Exp $
 *
 * @package     tgcSPL
 * @subpackage  Iterators
 * @access      public
 * @version     1.0.0
 * @author      Carsten Lucke <hide@address.com>
 */
class tgcSPL_DomNodeListIterator implements Iterator
{
    protected $nodeList;
    protected $itemNo;
    protected $name;
    protected $item;
    
    public function __construct(DomNodeList $nodeList)
    {
        $this->nodeList = $nodeList;
    }
    
    public function rewind()
    {
        $this->itemNo = 0;
    }
    
    public function valid()
    {
        return ($this->nodeList->item($this->itemNo)) ? true : false;
    }
    
    public function key()
    {
        return $this->nodeList->item($this->itemNo)->nodeName;
    }
    
    public function current()
    {
        return $this->nodeList->item($this->itemNo);
    }
    
    public function next()
    {
        ++$this->itemNo;
    }
}
?>
Return current item: tgcSPL