* @license LGPL (The GNU Lesser GPL) or an MIT-like license. */ require '../src/QueryPath/QueryPath.php'; $demo = '
  • Foo
  • Foo
  • Foo
  • Foo
  • Foo
  • '; $qp = qp($demo, 'data'); // Iterate over elements as DOMNodes: foreach ($qp->get() as $li_ele) { print $li_ele->tagName . PHP_EOL; // Prints 'li' five times. } // Iterate over elements as QueryPath objects foreach ($qp as $li_qp) { print $li_qp->tag() . PHP_EOL; // Prints 'li' five times } function callbackFunction($index, $element) { print $element->tagName . PHP_EOL; } // Iterate using a callback function $qp->each('callbackFunction'); // Iterate using a Lambda-style function $qp->eachLambda('return $item->tagName . PHP_EOL;'); // Loop through by index/count for ($i = 0; $i < $qp->size(); ++$i) { $domElement = $qp->get($i); print $domElement->tagName . PHP_EOL; }