A HTML DOM parser written in PHP7+ let you manipulate HTML-Node-Objects.
http://doc.alvine.io/de/alvine.markup.html/component/snapshot/
Download Library from http://download.alvine.io
wget http://download.alvine.io/alvine.markup.html-<version>.phar
wget http://download.alvine.io/alvine.markup.html-<version>.phar.pubkey
$html = \Alvine\Markup\Html\Fragment::getInstanceFromString('<b><i>Auto</i></b>');
echo (string) $html;
<b><i>Auto</i></b>
$html = \Alvine\Markup\Html\Fragment::getInstanceFromString('<b><i>Auto</i></b>');
/** div und Text einhängen */
$html->current()
->appendChild((new \Alvine\Markup\Html\Element\Html\Div())
->appendChild(new \Alvine\Markup\Html\Node\Text('Hallo World!')));
echo (string) $html;
<b><i>Auto</i><div>Hallo World!</div></b>
<div>
<p data-replace="dataset:text | strtolower | trim">My World</p>
</div>
<div>
<a data-attributes="href dataset:url | index:2 | strtolower, title string:Mein Titel | trim">My World</a>
</div>
$html = <<<EOF
<div>
<p data-replace="dataset:url">url</p>
</div>
EOF;
echo (new \Alvine\Markup\Html\Engine())
->setDataset((new \Alvine\Markup\Html\Dataset)
->setValue('url', new \Alvine\Net\Resource\URI('http://www.example.com')))
->getHTML($html);
<div>
<p>http://www.example.com</p>
</div>
echo (string) $fragment->find(new Selector('#opt2[class]'));
echo (string) $fragment->find(new Selector('li[class!="selected"]'));
https://wiki.schukai.com/display/alvine2/HTML+-+Programmierung