Nodes Traversable - ThomasWeinert/FluentDOM GitHub Wiki
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.
$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";
}
0: Hello
1: cruel
2: World