ILIAS  release_7 Revision v7.30-3-g800a261c036
ilHtmlDomNodeIterator Class Reference

Class ilHtmlDomNodeIterator. More...

+ Inheritance diagram for ilHtmlDomNodeIterator:
+ Collaboration diagram for ilHtmlDomNodeIterator:

Public Member Functions

 __construct (\DOMNode $el)
 ilHtmlDomNodeIterator constructor. More...
 
 key ()
 
 next ()
 
 current ()
 
 valid ()
 
 rewind ()
 
 hasChildren ()
 
 getChildren ()
 

Protected Attributes

 $position = 0
 
 $nodeList
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilHtmlDomNodeIterator::__construct ( \DOMNode  $el)

ilHtmlDomNodeIterator constructor.

Parameters
\DOMNode$el

Definition at line 20 of file class.ilHtmlDomNodeIterator.php.

21 {
22 $this->position = 0;
23 if ($el instanceof \DOMDocument) {
24 $root = $el->documentElement;
25 } else {
26 if ($el instanceof \DOMElement) {
27 $root = $el;
28 } else {
29 throw new \InvalidArgumentException("Invalid arguments, expected DOMElement or DOMDocument");
30 }
31 }
32
33 $this->nodeList = $root->childNodes;
34 }

Member Function Documentation

◆ current()

ilHtmlDomNodeIterator::current ( )

Returns
\DOMNode

Definition at line 56 of file class.ilHtmlDomNodeIterator.php.

57 {
58 return $this->nodeList->item($this->position);
59 }

Referenced by getChildren(), and hasChildren().

+ Here is the caller graph for this function:

◆ getChildren()

ilHtmlDomNodeIterator::getChildren ( )

Definition at line 88 of file class.ilHtmlDomNodeIterator.php.

89 {
90 return new self($this->current());
91 }

References current().

+ Here is the call graph for this function:

◆ hasChildren()

ilHtmlDomNodeIterator::hasChildren ( )

Definition at line 80 of file class.ilHtmlDomNodeIterator.php.

81 {
82 return $this->current()->hasChildNodes();
83 }

References current().

+ Here is the call graph for this function:

◆ key()

ilHtmlDomNodeIterator::key ( )

Definition at line 39 of file class.ilHtmlDomNodeIterator.php.

References $position.

◆ next()

ilHtmlDomNodeIterator::next ( )

Definition at line 47 of file class.ilHtmlDomNodeIterator.php.

48 {
49 $this->position++;
50 }

◆ rewind()

ilHtmlDomNodeIterator::rewind ( )

Definition at line 72 of file class.ilHtmlDomNodeIterator.php.

73 {
74 $this->position = 0;
75 }

◆ valid()

ilHtmlDomNodeIterator::valid ( )

Definition at line 64 of file class.ilHtmlDomNodeIterator.php.

65 {
66 return $this->position < $this->nodeList->length;
67 }

Field Documentation

◆ $nodeList

ilHtmlDomNodeIterator::$nodeList
protected

Definition at line 14 of file class.ilHtmlDomNodeIterator.php.

◆ $position

ilHtmlDomNodeIterator::$position = 0
protected

Definition at line 11 of file class.ilHtmlDomNodeIterator.php.

Referenced by key().


The documentation for this class was generated from the following file: