ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

References $root.

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  }
$root
Definition: sabredav.php:45

Member Function Documentation

◆ current()

ilHtmlDomNodeIterator::current ( )

Returns

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

Referenced by getChildren(), and hasChildren().

57  {
58  return $this->nodeList->item($this->position);
59  }
+ Here is the caller graph for this function:

◆ getChildren()

ilHtmlDomNodeIterator::getChildren ( )

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

References current().

89  {
90  return new self($this->current());
91  }
+ Here is the call graph for this function:

◆ hasChildren()

ilHtmlDomNodeIterator::hasChildren ( )

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

References current().

81  {
82  return $this->current()->hasChildNodes();
83  }
+ 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: