@@ -21,27 +21,29 @@ selects the last one on the page, and then selects its immediate ancestor elemen
21
21
Many other methods are also available:
22
22
23
23
``filter('h1.title') ``
24
- Nodes that match the CSS selector.
24
+ Selects nodes that match the given CSS selector (which must be supported by
25
+ Symfony's :doc: `CSS Selector component </components/css_selector >`).
25
26
``filterXpath('h1') ``
26
- Nodes that match the XPath expression.
27
+ Selects nodes matching the given ` XPath expression `_ .
27
28
``eq(1) ``
28
- Node for the specified index.
29
+ Selects the node at the given index (`` 0 `` is the first node)
29
30
``first() ``
30
- First node.
31
+ Selects the first node (equivalent to `` eq(0) ``) .
31
32
``last() ``
32
- Last node.
33
+ Selects the last node.
33
34
``siblings() ``
34
- Siblings .
35
+ Selects all sibling nodes (nodes with the same parent) .
35
36
``nextAll() ``
36
- All following siblings.
37
+ Selects all following siblings (same parent, after the current node) .
37
38
``previousAll() ``
38
- All preceding siblings.
39
+ Selects all preceding siblings (same parent, before the current node) .
39
40
``ancestors() ``
40
- Returns the ancestor nodes.
41
+ Selects all ancestor nodes (parents, grandparents, etc., up to the ``<html> ``
42
+ element).
41
43
``children() ``
42
- Returns children nodes.
44
+ Selects all direct child nodes of the current node .
43
45
``reduce($lambda) ``
44
- Nodes for which the callable does not return false .
46
+ Filters the nodes using a callback; keeps only those for which it returns `` true `` .
45
47
46
48
Since each of these methods returns a new ``Crawler `` instance, you can
47
49
narrow down your node selection by chaining the method calls::
@@ -91,3 +93,5 @@ The Crawler can extract information from the nodes::
91
93
$data = $crawler->each(function ($node, int $i): string {
92
94
return $node->attr('href');
93
95
});
96
+
97
+ .. _`XPath expression` : https://developer.mozilla.org/en-US/docs/Web/XML/XPath
0 commit comments