Skip to content

Commit 3802426

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [DomCrawler] Document innerText() method
2 parents a60b434 + b3fdbee commit 3802426

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

components/dom_crawler.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ Access the value of the first node of the current selection::
226226
// pass FALSE as the second argument to return the original text unchanged
227227
$crawler->filterXPath('//body/p')->text('Default text content', false);
228228

229+
// innerText() is similar to text() but returns only the text that is
230+
// the direct descendent of the current node, excluding any child nodes
231+
$text = $crawler->filterXPath('//body/p')->innerText();
232+
// if content is <p>Foo <span>Bar</span></p>
233+
// innerText() returns 'Foo' and text() returns 'Foo Bar'
234+
235+
.. versionadded:: 5.4
236+
237+
The ``innerText()`` method was introduced in Symfony 5.4.
238+
229239
Access the attribute value of the first node of the current selection::
230240

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

0 commit comments

Comments
 (0)