public function setInnerHtml($html)
    {
        if (!is_string($html)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, (is_object($html) ? get_class($html) : gettype($html))));
        }

        $this->removeChildren();

        if ($html !== '') {
            Errors::disable();

            $html = "<htmlfragment>$html</htmlfragment>";

            $document = new Document($html);

            $fragment = $document->first('htmlfragment')->getNode();

            foreach ($fragment->childNodes as $node) {
                $newNode = $this->node->ownerDocument->importNode($node, true);

                $this->node->appendChild($newNode);
            }

            Errors::restore();
        }

        return $this;
    }
public function setInnerHtml($html)
    {
        if (!is_string($html)) {
            throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, (is_object($html) ? get_class($html) : gettype($html))));
        }

        $this->removeChildren();

        if ($html !== '') {
            Errors::disable();

            $html = "<htmlfragment>$html</htmlfragment>";

            $document = new Document($html);

            $fragment = $document->first('htmlfragment')->getNode();

            foreach ($fragment->childNodes as $node) {
                $newNode = $this->node->ownerDocument->importNode($node, true);

                $this->node->appendChild($newNode);
            }

            Errors::restore();
        }

        return $this;
    }
public function setInnerHtml ( $ html ) { if ( ! is_string ( $ html ) ) { throw new InvalidArgumentException ( sprintf ( '%s expects parameter 1 to be string, %s given' , __METHOD__ , ( is_object ( $ html ) ? get_class ( $ html ) : gettype ( $ html ) ) ) ) ; } $ this -> removeChildren ( ) ; if ( $ html !== '' ) { Errors :: disable ( ) ; $ html = "<htmlfragment>$html</htmlfragment>" ; $ document = new Document ( $ html ) ; $ fragment = $ document -> first ( 'htmlfragment' ) -> getNode ( ) ; foreach ( $ fragment -> childNodes as $ node ) { $ newNode = $ this -> node -> ownerDocument -> importNode ( $ node , true ) ; $ this -> node -> appendChild ( $ newNode ) ; } Errors :: restore ( ) ; } return $ this ; }
Sets inner HTML.

@param string $html

@return \DiDom\Element

@throws InvalidArgumentException if passed argument is not a string
Sets inner HTML .