@@ -76,17 +76,6 @@ Node Filtering
7676Using XPath expressions is really easy::
7777
7878 $crawler = $crawler->filterXPath('descendant-or-self::body/p');
79-
80- // To chained "filterXPath" : be aware that filterXPath is evaluated in the context of the crawler
81- $crawler->filterXPath('parent')->each(function (Crawler $parentCrawler, $i) {
82- // NOK : Direct child can not be found
83- $childCrawler = $parentCrawler->filterXPath('child-tag/sub-child-tag');
84-
85- // OK : You must specify parent tag
86- $subChildCrawler = $parentCrawler->filterXPath('parent/child-tag/sub-child-tag');
87- $subChildCrawler = $parentCrawler->filterXPath('node()/child-tag/sub-child-tag');
88- });
89-
9079
9180.. tip ::
9281
@@ -235,6 +224,18 @@ Call an anonymous function on each node of the list::
235224The anonymous function receives the node (as a Crawler) and the position as arguments.
236225The result is an array of values returned by the anonymous function calls.
237226
227+ When using nested crawler, beware that ``filterXPath() `` is evaluated in the
228+ context of the crawler::
229+
230+ $crawler->filterXPath('parent')->each(function (Crawler $parentCrawler, $i) {
231+ // DON'T DO THIS: direct child can not be found
232+ $subCrawler = $parentCrawler->filterXPath('sub-tag/sub-child-tag');
233+
234+ // DO THIS: specify the parent tag too
235+ $subCrawler = $parentCrawler->filterXPath('parent/sub-tag/sub-child-tag');
236+ $subCrawler = $parentCrawler->filterXPath('node()/sub-tag/sub-child-tag');
237+ });
238+
238239Adding the Content
239240~~~~~~~~~~~~~~~~~~
240241
0 commit comments