File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,14 @@ 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+ Verify if the current node matches a selector::
169+
170+ $crawler->matches('p.lorem');
171+
172+ .. versionadded :: 4.4
173+
174+ The ``matches() `` method was introduced in Symfony 4.4.
175+
168176Node Traversing
169177~~~~~~~~~~~~~~~
170178
@@ -195,6 +203,14 @@ Get all the direct child nodes matching a CSS selector::
195203
196204 $crawler->filter('body')->children('p.lorem');
197205
206+ Get the first parents (heading toward the document root) of the element that matches the provided selector::
207+
208+ $crawler->closest('p.lorem');
209+
210+ .. versionadded :: 4.4
211+
212+ The ``closest() `` method was introduced in Symfony 4.4.
213+
198214.. note ::
199215
200216 All the traversal methods return a new :class: `Symfony\\ Component\\ DomCrawler\\ Crawler `
@@ -337,6 +353,15 @@ and :phpclass:`DOMNode` objects::
337353
338354 The default argument of ``html() `` was introduced in Symfony 4.3.
339355
356+ Or you can get the outer HTML of the first node using
357+ :method: `Symfony\\ Component\\ DomCrawler\\ Crawler::outerHtml `::
358+
359+ $html = $crawler->outerHtml();
360+
361+ .. versionadded :: 4.4
362+
363+ The ``outerHtml() `` method was introduced in Symfony 4.4.
364+
340365Expression Evaluation
341366~~~~~~~~~~~~~~~~~~~~~
342367
You can’t perform that action at this time.
0 commit comments