Skip to content
Thomas Weinert edited this page Jul 31, 2014 · 2 revisions

FluentDOM\Query::replaceAll()

FluentDOM\Query replaceAll(string|array|\DOMNode|\Traversable $selector);

Replaces the elements matched by the specified selector with the matched elements.

Usage

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

echo FluentDOM($html)
  ->add('<b id="sample">Paragraph. </b>')
  ->replaceAll('//p');

Output

<?xml version="1.0"?>
<html>
  <head>
    <title>Examples: FluentDOM\Query::replaceAll()</title>
  </head>
  <body>
    <div>
      <b id="sample">Paragraph. </b>
      <b id="sample">Paragraph. </b>
      <b id="sample">Paragraph. </b>
    </div>
  </body>
</html>
Clone this wiki locally