Skip to content
Thomas Weinert edited this page Jul 30, 2014 · 2 revisions

FluentDOM\Nodes Traversable

FluentDOM\Nodes implements the Traversable interface. More specific it implements IteratorAggregate.

The returned iterator is an recursive iterator. You can iterate the found nodes and their children.

Usage

$xml = <<<XML
<html>
<body>
  <p>Hello</p>
  <p>cruel</p>
  <p>World</p>
</body>
</html>
XML;

foreach (FluentDOM($xml)->find('//p') as $key => $value) {
  echo $key, ': ', $value, "\n";
}

Output

0: Hello
1: cruel
2: World
Clone this wiki locally