private static function getCleanedHTML(DOMDocument $doc, $container)
    {
        while ($doc->firstChild) {
            $doc->removeChild($doc->firstChild);
        }

        while ($container->firstChild ) {
            $doc->appendChild($container->firstChild);
        }

        $html = trim($doc->saveHTML());
        return $html;
    }