Skip to content

Commit 5beae1d

Browse files
committed
[DomCrawler] Added Crawler::matches(), ::closest(), ::outerHtml()
1 parent 581a296 commit 5beae1d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

components/dom_crawler.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,15 @@ Namespaces can be explicitly registered with the
165165
$crawler->registerNamespace('m', 'http://search.yahoo.com/mrss/');
166166
$crawler = $crawler->filterXPath('//m:group//yt:aspectRatio');
167167

168+
.. versionadded:: 4.4
169+
170+
The method ``matches()`` was introduced in Symfony 4.4.
171+
172+
Verify if the current node matches a selector::
173+
174+
$crawler->matches('p.lorem');
175+
176+
168177
Node Traversing
169178
~~~~~~~~~~~~~~~
170179

@@ -195,6 +204,14 @@ Get all the direct child nodes matching a CSS selector::
195204

196205
$crawler->filter('body')->children('p.lorem');
197206

207+
.. versionadded:: 4.4
208+
209+
The method ``closest()`` was introduced in Symfony 4.4.
210+
211+
Get the first parents (heading toward the document root) of the Element that matches the provided selector.
212+
213+
$crawler->closest('p.lorem');
214+
198215
.. note::
199216

200217
All the traversal methods return a new :class:`Symfony\\Component\\DomCrawler\\Crawler`
@@ -337,6 +354,13 @@ and :phpclass:`DOMNode` objects::
337354

338355
The default argument of ``html()`` was introduced in Symfony 4.3.
339356

357+
.. versionadded:: 4.4
358+
359+
The method ``outerHtml()`` was introduced in Symfony 4.4.
360+
361+
$html = $crawler->outerHtml();
362+
363+
340364
Expression Evaluation
341365
~~~~~~~~~~~~~~~~~~~~~
342366

0 commit comments

Comments
 (0)