ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilHtmlDomNodeIterator Class Reference

Class ilHtmlDomNodeIterator. More...

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

Public Member Functions

 __construct (DOMNode $el)
 
 key ()
 
 next ()
 
 current ()
 
 valid ()
 
 rewind ()
 
 hasChildren ()
 
 getChildren ()
 

Private Attributes

int $position
 
readonly DOMNodeList $nodeList
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilHtmlDomNodeIterator::__construct ( DOMNode  $el)

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

31 {
32 $this->position = 0;
33 if ($el instanceof DOMDocument) {
34 $root = $el->documentElement;
35 } elseif ($el instanceof DOMElement) {
36 $root = $el;
37 } else {
38 throw new InvalidArgumentException('Invalid arguments, expected DOMElement or DOMDocument');
39 }
40
41 $this->nodeList = $root->childNodes;
42 }

Member Function Documentation

◆ current()

ilHtmlDomNodeIterator::current ( )

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

54 : DOMNode
55 {
56 return $this->nodeList->item($this->position);
57 }

Referenced by getChildren(), and hasChildren().

+ Here is the caller graph for this function:

◆ getChildren()

ilHtmlDomNodeIterator::getChildren ( )

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

74 : self
75 {
76 return new self($this->current());
77 }

References current().

+ Here is the call graph for this function:

◆ hasChildren()

ilHtmlDomNodeIterator::hasChildren ( )

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

69 : bool
70 {
71 return $this->current()->hasChildNodes();
72 }

References current().

+ Here is the call graph for this function:

◆ key()

ilHtmlDomNodeIterator::key ( )

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

44 : int
45 {
46 return $this->position;
47 }

References $position.

◆ next()

ilHtmlDomNodeIterator::next ( )

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

49 : void
50 {
51 $this->position++;
52 }

◆ rewind()

ilHtmlDomNodeIterator::rewind ( )

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

64 : void
65 {
66 $this->position = 0;
67 }

◆ valid()

ilHtmlDomNodeIterator::valid ( )

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

59 : bool
60 {
61 return $this->position < $this->nodeList->length;
62 }

Field Documentation

◆ $nodeList

readonly DOMNodeList ilHtmlDomNodeIterator::$nodeList
private

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

◆ $position

int ilHtmlDomNodeIterator::$position
private

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

Referenced by key().


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