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
165
165
$crawler->registerNamespace('m', 'http://search.yahoo.com/mrss/');
166
166
$crawler = $crawler->filterXPath('//m:group//yt:aspectRatio');
167
167
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
+
168
176
Node Traversing
169
177
~~~~~~~~~~~~~~~
170
178
@@ -195,6 +203,14 @@ Get all the direct child nodes matching a CSS selector::
195
203
196
204
$crawler->filter('body')->children('p.lorem');
197
205
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
+
198
214
.. note ::
199
215
200
216
All the traversal methods return a new :class: `Symfony\\ Component\\ DomCrawler\\ Crawler `
@@ -337,6 +353,15 @@ and :phpclass:`DOMNode` objects::
337
353
338
354
The default argument of ``html() `` was introduced in Symfony 4.3.
339
355
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
+
340
365
Expression Evaluation
341
366
~~~~~~~~~~~~~~~~~~~~~
342
367
You can’t perform that action at this time.
0 commit comments