Query Add - ThomasWeinert/FluentDOM GitHub Wiki
FluentDOM\Query add(string $selector [, array|Traversable $context = NULL]);
Adds more elements, matched by the given expression, to the set of matched elements.
$xml = <<<XML
<html>
<head>
<title>Examples: FluentDOM\Query::add()</title>
</head>
<body>
<p>I would like to say: <b>HELLO</b></p>
<b>HELLO</b>
<div>Another list of childNodes</div>
</body>
</html>
XML;
require('../vendor/autoload.php');
$fdQuery = FluentDOM($xml);
echo $fdQuery
->find('//p')
->add('//p/b')
->toggleClass('inB');
<?xml version="1.0"?>
<html>
<head>
<title>Examples: FluentDOM\Query::add()</title>
</head>
<body>
<p class="inB">I would like to say: <b class="inB">HELLO</b></p>
<b>HELLO</b>
<div>Another list of childNodes</div>
</body>
</html>