Query Append - ThomasWeinert/FluentDOM GitHub Wiki
FluentDOM\Query append(string|array|\DOMNode|\Traversable|callable $content);
Append content to the inside of every matched element.
$html = <<<HTML
<html>
<head>
<title>Examples: FluentDOM\Query::append()</title>
</head>
<body>
<p>I would like to say: </p>
<items>
<group>
<item index="0">text1</item>
<item index="1">text2</item>
<item index="2">text3</item>
</group>
<html>
<div class="test1 test2"><b>class testing</b></div>
<div class="test2"><b>class testing</b></div>
</html>
</items>
</body>
</html>
HTML;
FluentDOM($html)
->find('//p')
->append('<strong>Hello</strong>')
->formatOutput();
<?xml version="1.0"?>
<html>
<head>
<title>Examples: FluentDOM\Query::append()</title>
</head>
<body>
<p>I would like to say: <strong>Hello</strong></p>
<items>
<group>
<item index="0">text1</item>
<item index="1">text2</item>
<item index="2">text3</item>
</group>
<html>
<div class="test1 test2">
<b>class testing</b>
</div>
<div class="test2">
<b>class testing</b>
</div>
</html>
</items>
</body>
</html>