-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[DomCrawler] Add more details about some methods #21034
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
base: 6.4
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,27 +21,29 @@ selects the last one on the page, and then selects its immediate ancestor elemen | |
Many other methods are also available: | ||
|
||
``filter('h1.title')`` | ||
Nodes that match the CSS selector. | ||
Selects nodes that match the given CSS selector (which must be supported by | ||
Symfony's :doc:`CSS Selector component </components/css_selector>`). | ||
``filterXpath('h1')`` | ||
Nodes that match the XPath expression. | ||
Selects nodes matching the given `XPath expression`_. | ||
``eq(1)`` | ||
Node for the specified index. | ||
Selects the node at the given index (``0`` is the first node) | ||
``first()`` | ||
First node. | ||
Selects the first node (equivalent to ``eq(0)``). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, but this doc is in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, if you improve the documentation of available methods to make it easier to know what they do (without going to another page), it is relevant to make it clear what they do IMO. Otherwise, you could remove the list and make them go to |
||
``last()`` | ||
Last node. | ||
Selects the last node. | ||
``siblings()`` | ||
Siblings. | ||
Selects all sibling nodes (nodes with the same parent). | ||
javiereguiluz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``nextAll()`` | ||
All following siblings. | ||
Selects all following siblings (same parent, after the current node). | ||
``previousAll()`` | ||
All preceding siblings. | ||
Selects all preceding siblings (same parent, before the current node). | ||
``ancestors()`` | ||
Returns the ancestor nodes. | ||
Selects all ancestor nodes (parents, grandparents, etc., up to the ``<html>`` | ||
element). | ||
javiereguiluz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``children()`` | ||
Returns children nodes. | ||
Selects all direct child nodes of the current node. | ||
``reduce($lambda)`` | ||
Nodes for which the callable does not return false. | ||
Filters the nodes using a callback; keeps only those for which it returns ``true``. | ||
|
||
Since each of these methods returns a new ``Crawler`` instance, you can | ||
narrow down your node selection by chaining the method calls:: | ||
|
@@ -91,3 +93,5 @@ The Crawler can extract information from the nodes:: | |
$data = $crawler->each(function ($node, int $i): string { | ||
return $node->attr('href'); | ||
}); | ||
|
||
.. _`XPath expression`: https://developer.mozilla.org/en-US/docs/Web/XML/XPath |
Uh oh!
There was an error while loading. Please reload this page.