the Following code will append html to element id main
I want to append content as html but it appended as text
$html='<div id="main"></div>';
$doc = new DOMDocument();
$doc->loadHTML('<?xml encoding="utf-8" ?>' .$html);
$el = $doc->getElementById('main');
$appended = $doc->createElement('div', '<div><h1> Hello world</h1></div>');
$el->appendChild($appended);
echo $doc->saveHTML();
current out
<h1> Hello world</h1>but I want
Hello world
Hello world
test