File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,10 @@ Access the value of the first node of the current selection::
220
220
// avoid the exception passing an argument that text() returns when node does not exist
221
221
$message = $crawler->filterXPath('//body/p')->text('Default text content');
222
222
223
+ // pass TRUE as the second argument of text() to remove all extra white spaces, including
224
+ // the internal ones (e.g. " foo\n bar baz \n " is returned as "foo bar baz")
225
+ $crawler->filterXPath('//body/p')->text('Default text content', true);
226
+
223
227
Access the attribute value of the first node of the current selection::
224
228
225
229
$class = $crawler->filterXPath('//body/p')->attr('class');
Original file line number Diff line number Diff line change @@ -688,6 +688,13 @@ The Crawler can extract information from the nodes::
688
688
// returns the node value for the first node
689
689
$crawler->text();
690
690
691
+ // returns the default text if the node does not exist
692
+ $crawler->text('Default text content');
693
+
694
+ // pass TRUE as the second argument of text() to remove all extra white spaces, including
695
+ // the internal ones (e.g. " foo\n bar baz \n " is returned as "foo bar baz")
696
+ $crawler->text(null, true);
697
+
691
698
// extracts an array of attributes for all nodes
692
699
// (_text returns the node value)
693
700
// returns an array for each element in crawler,
You can’t perform that action at this time.
0 commit comments