File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -201,8 +201,16 @@ Access the node name (HTML tag name) of the first node of the current selection
201
201
202
202
Access the value of the first node of the current selection::
203
203
204
+ // if the node does not exist, calling to text() will result in an exception
204
205
$message = $crawler->filterXPath('//body/p')->text();
205
206
207
+ // avoid the exception passing an argument that text() returns when node does not exist
208
+ $message = $crawler->filterXPath('//body/p')->text('Default text content');
209
+
210
+ .. versionadded :: 4.3
211
+
212
+ The default argument of ``text() `` was introduced in Symfony 4.3.
213
+
206
214
Access the attribute value of the first node of the current selection::
207
215
208
216
$class = $crawler->filterXPath('//body/p')->attr('class');
@@ -298,8 +306,16 @@ and :phpclass:`DOMNode` objects::
298
306
Or you can get the HTML of the first node using
299
307
:method: `Symfony\\ Component\\ DomCrawler\\ Crawler::html `::
300
308
309
+ // if the node does not exist, calling to html() will result in an exception
301
310
$html = $crawler->html();
302
311
312
+ // avoid the exception passing an argument that html() returns when node does not exist
313
+ $html = $crawler->html('Default <strong>HTML</strong> content');
314
+
315
+ .. versionadded :: 4.3
316
+
317
+ The default argument of ``html() `` was introduced in Symfony 4.3.
318
+
303
319
Expression Evaluation
304
320
~~~~~~~~~~~~~~~~~~~~~
305
321
You can’t perform that action at this time.
0 commit comments