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 @@ -161,6 +161,14 @@ Namespaces can be explicitly registered with the
161161 $crawler->registerNamespace('m', 'http://search.yahoo.com/mrss/');
162162 $crawler = $crawler->filterXPath('//m:group//yt:aspectRatio');
163163
164+ Verify if the current node matches a selector::
165+
166+ $crawler->matches('p.lorem');
167+
168+ .. versionadded :: 4.4
169+
170+ The ``matches() `` method was introduced in Symfony 4.4.
171+
164172Node Traversing
165173~~~~~~~~~~~~~~~
166174
@@ -191,6 +199,14 @@ Get all the direct child nodes matching a CSS selector::
191199
192200 $crawler->filter('body')->children('p.lorem');
193201
202+ Get the first parents (heading toward the document root) of the element that matches the provided selector::
203+
204+ $crawler->closest('p.lorem');
205+
206+ .. versionadded :: 4.4
207+
208+ The ``closest() `` method was introduced in Symfony 4.4.
209+
194210.. note ::
195211
196212 All the traversal methods return a new :class: `Symfony\\ Component\\ DomCrawler\\ Crawler `
@@ -321,6 +337,15 @@ and :phpclass:`DOMNode` objects::
321337 // avoid the exception passing an argument that html() returns when node does not exist
322338 $html = $crawler->html('Default <strong>HTML</strong> content');
323339
340+ Or you can get the outer HTML of the first node using
341+ :method: `Symfony\\ Component\\ DomCrawler\\ Crawler::outerHtml `::
342+
343+ $html = $crawler->outerHtml();
344+
345+ .. versionadded :: 4.4
346+
347+ The ``outerHtml() `` method was introduced in Symfony 4.4.
348+
324349Expression Evaluation
325350~~~~~~~~~~~~~~~~~~~~~
326351
You can’t perform that action at this time.
0 commit comments