Skip to content
Thomas Weinert edited this page Jul 31, 2014 · 1 revision

FluentDOM\Query::text()

FluentDOM\Query|string text([ string $text = NULL ]);

Get the combined text contents of all matched elements or set the text contents of all matched elements.

Usage

$html = <<<HTML
<html>
  <head>
    <title>Examples: FluentDOM\Query::text()</title>
  </head>
  <body>
    <div>
      <p>Hello</p>
      <p>cruel</p>
      <p>World!</p>
    </div>
  </body>
</html>
HTML;

echo FluentDOM($html)
  ->find('//p[position() = 2]')
  ->text('nice');

Output

<?xml version="1.0"?>
<html>
  <head>
    <title>Examples: FluentDOM\Query::text()</title>
  </head>
  <body>
    <div>
      <p>Hello</p>
      <p>nice</p>
      <p>World!</p>
    </div>
  </body>
</html>
Clone this wiki locally