protected function _cleanDocument(DOMDocument $doc)
{
/* clean document */
if ($doc->firstChild->nodeType === XML_DOCUMENT_TYPE_NODE) {
/* remove doctype */
$doc->removeChild($doc->firstChild);
/* remove head and body */
if ($doc->firstChild->firstChild->nodeName === 'head' || $doc->firstChild->firstChild->nodeName === 'body') {
$doc->replaceChild($doc->firstChild->firstChild->firstChild, $doc->firstChild);
}
}
return $doc;
}