File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -229,6 +229,18 @@ Call an anonymous function on each node of the list::
229229The anonymous function receives the node (as a Crawler) and the position as arguments.
230230The result is an array of values returned by the anonymous function calls.
231231
232+ When using nested crawler, beware that ``filterXPath() `` is evaluated in the
233+ context of the crawler::
234+
235+ $crawler->filterXPath('parent')->each(function (Crawler $parentCrawler, $i) {
236+ // DON'T DO THIS: direct child can not be found
237+ $subCrawler = $parentCrawler->filterXPath('sub-tag/sub-child-tag');
238+
239+ // DO THIS: specify the parent tag too
240+ $subCrawler = $parentCrawler->filterXPath('parent/sub-tag/sub-child-tag');
241+ $subCrawler = $parentCrawler->filterXPath('node()/sub-tag/sub-child-tag');
242+ });
243+
232244Adding the Content
233245~~~~~~~~~~~~~~~~~~
234246
You can’t perform that action at this time.
0 commit comments