Redaxscript\Filter\Html::_cleanDocument PHP 메소드

_cleanDocument() 보호된 메소드

clean the document
부터: 2.6.0
protected _cleanDocument ( DOMDocument $doc ) : DOMDocument
$doc DOMDocument target document
리턴 DOMDocument
    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;
    }