Skip to content

Commit 32adb8e

Browse files
committed
Merge branch '4.4'
* 4.4: Documented the DomCrawler option to normalize white spaces
2 parents 35645ec + c746a77 commit 32adb8e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

components/dom_crawler.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ Access the value of the first node of the current selection::
220220
// avoid the exception passing an argument that text() returns when node does not exist
221221
$message = $crawler->filterXPath('//body/p')->text('Default text content');
222222

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+
223227
Access the attribute value of the first node of the current selection::
224228

225229
$class = $crawler->filterXPath('//body/p')->attr('class');

testing.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,13 @@ The Crawler can extract information from the nodes::
688688
// returns the node value for the first node
689689
$crawler->text();
690690

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+
691698
// extracts an array of attributes for all nodes
692699
// (_text returns the node value)
693700
// returns an array for each element in crawler,

0 commit comments

Comments
 (0)