ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 

Protected Attributes

int $position = 0
 
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.

Referenced by getChildren(), and hasChildren().

54  : DOMNode
55  {
56  return $this->nodeList->item($this->position);
57  }
+ Here is the caller graph for this function:

◆ getChildren()

ilHtmlDomNodeIterator::getChildren ( )

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

References current().

74  : self
75  {
76  return new self($this->current());
77  }
+ Here is the call graph for this function:

◆ hasChildren()

ilHtmlDomNodeIterator::hasChildren ( )

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

References current().

69  : bool
70  {
71  return $this->current()->hasChildNodes();
72  }
+ Here is the call graph for this function:

◆ key()

ilHtmlDomNodeIterator::key ( )

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

References $position.

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

◆ 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

DOMNodeList ilHtmlDomNodeIterator::$nodeList
protected

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

◆ $position

int ilHtmlDomNodeIterator::$position = 0
protected

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

Referenced by key().


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