Skip to content

[DomCrawler] each() iterates over items as Crawlers #2638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/dom_crawler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ Extract attribute and/or node values from the list of nodes::
Call an anonymous function on each node of the list::

$nodeValues = $crawler->filter('p')->each(function ($node, $i) {
return $node->nodeValue;
return $node->text();
});

The anonymous function receives the position and the node as arguments.
The anonymous function receives the position and the node (as a Crawler) as arguments.
The result is an array of values returned by the anonymous function calls.

Adding the Content
Expand All @@ -163,7 +163,7 @@ The crawler supports multiple ways of adding the content::
.. note::

When dealing with character sets other than ISO-8859-1, always add HTML
content using the :method:`Symfony\\Component\\DomCrawler\\Crawler::addHTMLContent``
content using the :method:`Symfony\\Component\\DomCrawler\\Crawler::addHTMLContent`
method where you can specify the second parameter to be your target character
set.

Expand Down