I downloaded the latest version of the framework and the html component.
And this code works perfectly and gives the desired result.
$html=\Alvine\Markup\Html\Fragment::getInstanceFromString('
<div>
<article>
<p class="first"></p>
<p>Lorem Ipsum</p>
</article>
</div>
');
$node=$html->find(new \Alvine\Markup\Html\Constraint\Attribute('class'));
$current=$node->current();
$current->appendChild(new \Alvine\Markup\Html\Element\Html\H1('my headline'));
echo (string) $html;
but somehow I do not manage to adjust the search so that I can search a tag with an id.
With the base class you can perform this query.
<div>
<article>
<p class="first"></p>
<p id="myID">Lorem Ipsum</p>
</article>
</div>
$fragment = \Alvine\Markup\Html\Fragment::getInstanceFromString($html);
echo (string) $fragment->find(new Selector('#myID'));
// <p id="myID">Lorem Ipsum</p>
echo (string) $fragment->find(new Selector('.first'));
// <p class="first"></p>
see https://doc.alvine.io/de/alvine.markup.html/api/snapshot/Alvine/Markup/Html/Constraint/Selector.html