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 @@ -252,6 +252,18 @@ Call an anonymous function on each node of the list::
252
252
The anonymous function receives the node (as a Crawler) and the position as arguments.
253
253
The result is an array of values returned by the anonymous function calls.
254
254
255
+ When using nested crawler, beware that ``filterXPath() `` is evaluated in the
256
+ context of the crawler::
257
+
258
+ $crawler->filterXPath('parent')->each(function (Crawler $parentCrawler, $i) {
259
+ // DON'T DO THIS: direct child can not be found
260
+ $subCrawler = $parentCrawler->filterXPath('sub-tag/sub-child-tag');
261
+
262
+ // DO THIS: specify the parent tag too
263
+ $subCrawler = $parentCrawler->filterXPath('parent/sub-tag/sub-child-tag');
264
+ $subCrawler = $parentCrawler->filterXPath('node()/sub-tag/sub-child-tag');
265
+ });
266
+
255
267
Adding the Content
256
268
~~~~~~~~~~~~~~~~~~
257
269
You can’t perform that action at this time.
0 commit comments