QueryPath\DOMQuery::html PHP Method

html() public method

If $markup is set, then the giving markup will be injected into each item in the set. All other children of that node will be deleted, and this new code will be the only child or children. The markup MUST BE WELL FORMED. If no markup is given, this will return a string representing the child markup of the first node. Important: This differs from jQuery's html() function. This function returns the current node and all of its children. jQuery returns only the children. This means you do not need to do things like this:
See also: xml()
See also: text()
See also: contents()
public html ( string $markup = null ) : mixed
$markup string The text to insert.
return mixed A string if no markup was passed, or a DOMQuery if markup was passed.
    public function html($markup = null)
    {
        if (isset($markup)) {
            if ($this->options['replace_entities']) {
                $markup = \QueryPath\Entities::replaceAllEntities($markup);
            }
            // Parse the HTML and insert it into the DOM
            //$doc = DOMDocument::loadHTML($markup);
            $doc = $this->document->createDocumentFragment();
            $doc->appendXML($markup);
            $this->removeChildren();
            $this->append($doc);
            return $this;
        }
        $length = $this->size();
        if ($length == 0) {
            return;
        }
        // Only return the first item -- that's what JQ does.
        $first = $this->getFirstMatch();
        // Catch cases where first item is not a legit DOM object.
        if (!$first instanceof \DOMNode) {
            return;
        }
        // Added by eabrand.
        if (!$first->ownerDocument->documentElement) {
            return;
        }
        if ($first instanceof \DOMDocument || $first->isSameNode($first->ownerDocument->documentElement)) {
            return $this->document->saveHTML();
        }
        // saveHTML cannot take a node and serialize it.
        return $this->document->saveXML($first);
    }