This library provides a rule based dom document manipulator.
This library can be installed using composer
$ php composer.phar require netzmacht/php-dom-manipulator:~1.0
$ php composer.phar update
<?php
$converter = new Netzmacht\DomManipulator\Converter\DomDocumentConverter();
$manipulator = new Netzmacht\DomManipulator\DomManipulator($converter);
$query = new Netzmacht\DomManipulator\Query\XPathQuery('xpath query');
$rule = new Netzmacht\DomManipulator\Rule\AttributeRule($query, 'class');
$result = $manipulator
->addRule($rule)
->loadHtml('<html> </html>')
->manipulate();
This library initially was extracted from the toflar/contao-css-class-replacer which is maintained by Yanick Witschi alias @Toflar.