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

FluentDOM\Query::wrapInner()

FluentDOM\Query wrapInner(string|array|\DOMNode|\Traversable|callable $content);

Wrap the inner child contents of each matched element (including text nodes) with an XML structure.

Usage

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

echo FluentDOM($html)
  ->find('//p')
  ->wrapInner('<b></b>');

Output

<?xml version="1.0"?>
<html>
  <head>
    <title>Examples: FluentDOM\Query::wrapInner()</title>
  </head>
  <body>
    <p><b>Hello</b></p>
    <p><b>cruel</b></p>
    <p><b>World</b></p>
  </body>
</html>
Clone this wiki locally