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
161
161
$crawler->registerNamespace('m', 'http://search.yahoo.com/mrss/');
162
162
$crawler = $crawler->filterXPath('//m:group//yt:aspectRatio');
163
163
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
+
164
172
Node Traversing
165
173
~~~~~~~~~~~~~~~
166
174
@@ -191,6 +199,14 @@ Get all the direct child nodes matching a CSS selector::
191
199
192
200
$crawler->filter('body')->children('p.lorem');
193
201
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
+
194
210
.. note ::
195
211
196
212
All the traversal methods return a new :class: `Symfony\\ Component\\ DomCrawler\\ Crawler `
@@ -321,6 +337,15 @@ and :phpclass:`DOMNode` objects::
321
337
// avoid the exception passing an argument that html() returns when node does not exist
322
338
$html = $crawler->html('Default <strong>HTML</strong> content');
323
339
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
+
324
349
Expression Evaluation
325
350
~~~~~~~~~~~~~~~~~~~~~
326
351
You can’t perform that action at this time.
0 commit comments