protected function cleaningHtml($html)
    {
        $xml = false;
        $childrens = null;

        try {
            $xml = @simplexml_load_string($html);
        } catch (\Exception $e) {
            // ignore
        }

        if ($xml !== false) {
            if (!$this->hasHead && $xml->getName() === 'head') {
                $childrens = $xml->xpath('//head/child::*');
            }
            if (!$this->hasBody && $xml->getName() === 'body') {
                $childrens = $xml->xpath('//body/child::*');
            }

            if ($childrens !== null) {
                $temp = '';
                foreach ($childrens as $children) {
                    $temp .= $children->saveXML();
                }
                $html = html_entity_decode($temp);
            }
        }

        if ($this->hasHtml) {
            $html = $this->htmlMatches['before'].$html.$this->htmlMatches['after'];
        }
        if ($this->hasDoctype) {
            $html = $this->doctypeMatches['content'].$html;
        }

        return $html;
    }
protected function cleaningHtml($html)
    {
        $xml = false;
        $childrens = null;

        try {
            $xml = @simplexml_load_string($html);
        } catch (\Exception $e) {
            // ignore
        }

        if ($xml !== false) {
            if (!$this->hasHead && $xml->getName() === 'head') {
                $childrens = $xml->xpath('//head/child::*');
            }
            if (!$this->hasBody && $xml->getName() === 'body') {
                $childrens = $xml->xpath('//body/child::*');
            }

            if ($childrens !== null) {
                $temp = '';
                foreach ($childrens as $children) {
                    $temp .= $children->saveXML();
                }
                $html = html_entity_decode($temp);
            }
        }

        if ($this->hasHtml) {
            $html = $this->htmlMatches['before'].$html.$this->htmlMatches['after'];
        }
        if ($this->hasDoctype) {
            $html = $this->doctypeMatches['content'].$html;
        }

        return $html;
    }
protected function cleaningHtml ( $ html ) { $ xml = false ; $ childrens = null ; try { $ xml = @ simplexml_load_string ( $ html ) ; } catch ( \ Exception $ e ) { // ignore } if ( $ xml !== false ) { if ( ! $ this -> hasHead && $ xml -> getName ( ) === 'head' ) { $ childrens = $ xml -> xpath ( '//head/child::*' ) ; } if ( ! $ this -> hasBody && $ xml -> getName ( ) === 'body' ) { $ childrens = $ xml -> xpath ( '//body/child::*' ) ; } if ( $ childrens !== null ) { $ temp = '' ; foreach ( $ childrens as $ children ) { $ temp .= $ children -> saveXML ( ) ; } $ html = html_entity_decode ( $ temp ) ; } } if ( $ this -> hasHtml ) { $ html = $ this -> htmlMatches [ 'before' ] . $ html . $ this -> htmlMatches [ 'after' ] ; } if ( $ this -> hasDoctype ) { $ html = $ this -> doctypeMatches [ 'content' ] . $ html ; } return $ html ; }
Cleaning HTML from parts it should not contains

@param string $html

@return string
Cleaning HTML from parts it should not contains