Enter description here...

@param  unknown_type $html
@param  unknown_type $domId
@return unknown New DOM ID
@todo   support PHP tags in input
@todo   support passing DOMDocument object from self::loadDocument
337938
protected static function createDocumentWrapper($html, $contentType = null, $documentID = null) 
    {
        if (function_exists('domxml_open_mem')) {
            throw new Exception("Old PHP4 DOM XML extension detected. phpQuery won't work until this extension is enabled.");
        }
        //        $id = $documentID
        //            ? $documentID
        //            : md5(microtime());
        $document = null;
        if ($html instanceof DOMDOCUMENT) {
            if (self::getDocumentID($html)) {
                // document already exists in phpQuery::$documents, make a copy
                $document = clone $html;
            } else {
                // new document, add it to phpQuery::$documents
                $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID);
            }
        } else {
            $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID);
        }
        //        $wrapper->id = $id;
        // bind document
        phpQuery::$documents[$wrapper->id] = $wrapper;
        // remember last loaded document
        phpQuery::selectDocument($wrapper->id);
        return $wrapper->id;
    }
994397
public static function newDocumentXHTML($markup = null, $charset = null) 
    {
        $contentType = $charset
        ? ";charset=$charset"
        : '';
        return self::newDocument($markup, "application/xhtml+xml{$contentType}");
    }
419989
private function createMetadataNode(\DOMDocument $document, string $type = null): \DOMNode
    {
        $node = $document->createElement('object');
        if (null !== $type) {
            $node->setAttribute('type', $type);
        }

        return $node;
    }
897678
public static function setHTML($id, $html)
    {
        $js = '$("'.$id.'").html('.json_encode($html).');';
        return self::execHeader($js);
    }
1187134
private static function createTypeElement(\DOMDocument $document, $parentElement = null, $type)
    {
        if ($parentElement->parentNode === null) {
            $typeElement = $document->createElementNS(
                'https://github.com/RhubarbPHP/Rhubarb/blob/master/docs/simple-xml-transcoder.md',
                self::XMLNS . ':' . $type
            );
            $parentElement->appendChild($typeElement);
        } else {
            $parentElement->setAttribute(self::XMLNS . ':' . self::ATTR_TYPE, $type);
            $typeElement = $parentElement;
        }

        return $typeElement;
    }
1263025
public function html($name, $html, array $attr = null)
    {
        return $this->input($name, [ 'type' => 'html', 'html' => $html, 'attr' => $attr ]);
    }
411805
public function transform($xslDocument)
    {
        if ($xslDocument->domDocument) {
            $processor = new \XsltProcessor();
            $processor->importStylesheet($xslDocument->domDocument);
            $htmlDomDocument = new self;
            $htmlDomDocument->domDocument = $processor->transformToDoc($this->domDocument);

            if (!$htmlDomDocument->domDocument) {
                throw new Dom\Exception('The XSL transformation has failed.');
            }
        } else {
            throw new Dom\Exception('There is no XSL template to transform with.');
        }

        try {
            return $htmlDomDocument->toString(false);
        } catch (\Exception $exception) {
            $this->logger->error($exception->getMessage());
            throw new Dom\Exception("dom-transform-failed");
        }
    }
812897
public function loadHTML($html)
    {
        $dom = new \DOMDocument();

        libxml_use_internal_errors(true);
        $dom->loadHTML($html, LIBXML_NOWARNING);
        $errors = libxml_get_errors();
        libxml_use_internal_errors(false);

        // Run through all errors
        /** @var \LibXMLError $error */
        foreach ($errors as $error) {
            throw new InvalidArgumentException(
                sprintf(InvalidArgumentException::INVALID_HTML_STR, trim($error->message)),
                InvalidArgumentException::INVALID_HTML
            );
        }

        return $dom;
    }
1251130
public function toDOM(\DOMDocument $doc): \DOMNode
    {
        $paragraph = $doc->createElement('p');

        $this->customAttributesToDOM($paragraph);
        $this->containerToDOM($doc, $paragraph);

        return $paragraph;
    }
1311436
public function html(string $html, array $parentAttributes = [])
    {
        return $this->add(Html::raw($html)->setParentAttributes($parentAttributes));
    }
874871
public function setHtml($html = null)
    {
        $html = trim($html);
        $this->html = 0 < strlen($html) ? $html : null;

        return $this;
    }
586064
private function fillElement (DOMDocument $doc, DOMElement $parent, array $filler)
    {
        foreach ($filler as $name => $value) {
            if ($value instanceof DOMElement) {
                $element = $value;
            } else {
                $element = $doc->createElement($name);
                
                if (is_array($value)) {
                    $this->fillElement($doc, $element, $value);
                } else {
                    $element->appendChild(new DOMCdataSection($value));
                }
            }
            
            $parent->appendChild($element);
        }
    }
271654
public function htmlModal($identifier, $title="", $content="", $buttonCaptions=array()) {
		return $this->addHtmlComponent(new HtmlModal($identifier, $title, $content, $buttonCaptions));
	}
117681
public function req_dom($path = '/', $method = 'GET', $input='',$option = [])
    {
        $html = $this->req($path, $method, $input, $option);
        $dom = new \PHPHtmlParser\Dom;
        $dom->load($html);

        return $dom;
    }
1160449
public static HtmlTree A_ID(String id, Content body) {
        HtmlTree htmltree = new HtmlTree(HtmlTag.A);
        htmltree.addAttr(HtmlAttr.ID, nullCheck(id));
        htmltree.addContent(nullCheck(body));
        return htmltree;
    }
1310000
protected function appendHTML(DOMElement $elem, string $html): DOMElement
   {
       try {
           $dom = new DOMDocument();
           $this->loadHTML($dom, $html);
           foreach($dom->childNodes as $node) {
               if ($node instanceof DOMElement) {
                   $elem->appendChild($this->template->createTextNode("\n"));
                   $elem->appendChild($this->template->importNode($node, true));
               }
           }
           return $elem;
       } catch (Throwable $e) {
           throw new RuntimeException("Can't append HTML: " . $e->getMessage());
       }
   }
427826
public function discoverFromHtml($html)
    {
        $links = $this->findLinks($html);

        if ( ! $link = reset($links)) {
            return;
        }

        $type = null;

        switch($link['type']) {
        case 'application/json+oembed':
            $type = Provider::TYPE_JSON;
            break;
        case 'text/xml+oembed':
            $type = Provider::TYPE_XML;
            break;
        }

        $url = $link['href'];
        $endpoint = $this->getEndpointUrl($url);

        return new Provider($endpoint, $type);
    }