/*
设置dom结构
@return string
547024
public static function dom(){
        $attr = self::$attr;
        $id = self::$attr['id'];

        $attr['placeholder'] = $attr['placeholder'] ? $attr['placeholder'] : $attr['label'];

        $attr['readonly'] = ($attr['readonly'] == '1') ? 'readonly' : '';

        $dom = <<<EOT
            <div class="layui-form-item" component-name="{$attr['component_name']}">
                <label class="layui-form-label">{$attr['label']}</label>
                <div class="layui-input-{$attr['display']}">
                    <input id="{$id}"  lay-verify="{$attr['layVerify']}" class="layui-input {$attr['component_name']} {$attr['classname']}" value="{$attr['value']}" name="{$attr['name']}" placeholder="{$attr['placeholder']}" {$attr['readonly']}>
                </div>
                <div class="layui-form-mid layui-word-aux">{$attr['helpinfo']}</div>
            </div>
EOT;

        return $dom;
    }
741112
protected function getContent()
    {
        $dom = new DOMDocument('1.0');
        $dom->loadXML($this->string);
        $dom->preserveWhiteSpace = false;
        $dom->formatOutput = true;

        return $dom->saveXML();
    }
92079
public function getXML(){
		$doc = new \DomDocument('1.0');
		$doc->preserveWhiteSpace = false;
		$doc->formatOutput = true;
		$doc->loadXML($this->dom->asXml());
		return $doc->saveXML();
	}
756715
public function getHtml(): string
  {
    $this->attributes['name'] = $this->submitName;

    $html = $this->prefix;
    $html .= $this->getHtmlPrefixLabel();
    $html .= Html::generateTag('select', $this->attributes);

    // Normalize current value as a string.
    $valueAsString = Cast::toManString($this->value, '');

    // Add an empty option, if necessary.
    if ($this->emptyOption!==null)
    {
      $optionAttributes = ['value'    => $this->emptyOption,
                           'selected' => ($valueAsString===Cast::toManString($this->emptyOption, ''))];

      $html .= Html::generateElement('option', $optionAttributes, ' ');
    }

    if (is_array($this->options))
    {
      foreach ($this->options as $option)
      {
        $optionAttributes = $this->optionAttributes($option);

        // Get the (database) key of the option.
        $key         = $option[$this->keyKey];
        $keyAsString = Cast::toManString($key, '');

        // If an obfuscator is installed compute the obfuscated code of the (database) ID.
        $code = ($this->optionsObfuscator) ? $this->optionsObfuscator->encode(Cast::toOptInt($key)) : $keyAsString;

        $optionAttributes['value']    = $code;
        $optionAttributes['selected'] = ($valueAsString===$keyAsString);

        $html .= Html::generateElement('option', $optionAttributes, Cast::toOptString($option[$this->labelKey]));
      }
    }

    $html .= '</select>';
    $html .= $this->getHtmlPostfixLabel();
    $html .= $this->postfix;

    return $html;
  }
524365
public function asDom(): \DOMDocument
    {
        $doc = new \DOMDocument();
        $doc->loadXML($this->writer->outputMemory());
        return $doc;
    }
100820
public function saveHTML()
    {
        if ($this->isHtmlDocument()) {
            return $this->getDOMDocument()->saveHTML();
        } else {
            $doc = new \DOMDocument('1.0', 'UTF-8');
            $root = $doc->appendChild($doc->createElement('_root'));
            foreach ($this as $node) {
                $root->appendChild($doc->importNode($node, true));
            }
            $html = trim($doc->saveHTML());
            return preg_replace('@^<'.self::FRAGMENT_ROOT_TAGNAME.'[^>]*>|</'.self::FRAGMENT_ROOT_TAGNAME.'>$@', '', $html);
        }
    }
846530
protected function get_element_markup() {
		$select_markup = "<select {$this->get_id_and_class_markup()}>";
		$value         = $this->get_value();

		foreach ( $this->option_values as $option_value => $display ) {
			$select_markup .= '<option value="' . \esc_attr( $option_value ) . '" ' . \selected( $value, $option_value, false ) . '>' . \esc_html( $display ) . '</option>';
		}
		$select_markup .= '</select>';

		return $select_markup;
	}
91320
public function getHTML()
    {
        $html = '';
        switch (arg('action'))
        {
            case 'add':
                $html = $this->actionAddDialog();
                break;

            case 'create':
                $html = $this->actionCreate();
                break;

            default:

                switch (true)
                {
                    case arg('edit'):
                        $html = $this->actionEditDialog(arg('edit'));
                        break;

                    case arg('update'):
                        $html = $this->actionUpdate();
                        break;

                    case arg('delete'):
                        $this->actionDelete(arg('delete'));
                        break;

                    default:
                        $html = $this->actionIndex();
                }
                break;
        }
        return $html;
    }
424007
public function getForm()
    {
        $elementString = '';

        if (isset($this->attributes[self::$formHolder[self::$formName]])) {
            $elementString .= $this->attributes[self::$formHolder[self::$formName]][self::$formName];
        }

        $elementString .= $this->getHtmlElements();

        $close = null;
        $close = self::$formHolder[self::$formName].'_close';

        if (isset($this->attributes[$close])) {
            $elementString .= $this->attributes[$close];
        }

        return $this->element[self::$formHolder[self::$formName]] = $elementString;
    }
1077948
function toHtml(){
        $retval = '';
        if ($this->_hiddenLabel){
            $this->_generateId();
            $retval = '<label class="accesshide" for="'.$this->getAttribute('id').'" >'.
                        $this->getLabel().'</label>'.parent::toHtml();
        } else {
             $retval = parent::toHtml();
        }

        if (!empty($this->_link)) {
            if (!empty($this->_linkreturn) && is_array($this->_linkreturn)) {
                $appendchar = '?';
                if (strstr($this->_link, '?')) {
                    $appendchar = '&amp;';
                }

                foreach ($this->_linkreturn as $key => $val) {
                    $this->_link .= $appendchar."$key=$val";
                    $appendchar = '&amp;';
                }
            }

            $retval .= '<a style="margin-left: 5px" href="'.$this->_link.'">'.$this->_linklabel.'</a>';
        }

        return $retval;
    }
1356333
public function getHtml()
    {
        $code = $this->code;

        if (empty($code)) {
            return;
        }

        $errors = libxml_use_internal_errors(true);
        $entities = libxml_disable_entity_loader(true);

        $dom = new \DOMDocument();
        $dom->loadHTML($code);

        libxml_use_internal_errors($errors);
        libxml_disable_entity_loader($entities);

        return Utils::xpathQuery($dom, 'descendant-or-self::body/*', false);
    }
504915
public function html() {
    if (($el = $this->getElement()) === NULL) return NULL;
    
    return implode('',xml::export($el->childNodes));
  }
911672
public function getHtmlBody()
    {
        $xpath = new DOMXPath($this->_doc);
        $bodyNodes = $xpath->query('/html/body')->item(0)->childNodes;

        $outputFragments = array();
        for ($count = 0; $count < $bodyNodes->length; $count++) {
            $outputFragments[] = $this->_doc->saveXML($bodyNodes->item($count));
        }

        return implode($outputFragments);
    }
740256
function toHtml()
    {
        $tabs    = $this->_getTabs();
        $name    = $this->getPrivateName();
        $strHtml = '';

        foreach ($this->_values as $key => $val) {
            for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) {
                if ($val == $this->_options[$i]['attr']['value']) {
                    $strHtml .= $tabs . '<input' . $this->_getAttrString(array(
                        'type'  => 'hidden',
                        'name'  => $name,
                        'value' => $val
                    )) . " />\n" ;
                }
            }
        }

        return $strHtml;
    }
990792
public function getOuterHtml()
    {
        $outer_html = '';

        if ($this->xml_mode && $this->xml_print_pi) {
            $outer_html .= '<?xml version="'.$this->document->xmlVersion.'" encoding="'.$this->document->xmlEncoding.'"?>';
            $outer_html .= "\n\n";
        }

        foreach ($this->nodes as $node) {
            if (isset($this->document)) {
                if ($this->xml_mode) {
                    $outer_html .= $this->document->saveXML($node);
                } else {
                    $outer_html .= $this->document->saveHTML($node);
                }
            }
        }

        $outer_html = $this->handleHtmlResult($outer_html);

        return $outer_html;
    }
386045
public function getElementId()
    {
        $id = $this->getAttribute('elementId');
        if (null === $id && null !== $this->element) {
            $id = $this->elementId = $this->element->id;
        }

        return $id;
    }
343765
protected function getCssContent()
    {
        $styleString = "";

        if (class_exists("\\DOMDocument")) {
            $doc = new \DOMDocument();
            $doc->loadHTMLFile($this->getFilename());

            // Extract styles from the HTML file
            foreach($doc->getElementsByTagName('style') as $styleNode) {
                $styleString .= $styleNode->nodeValue . "\r\n";
            }
        } else {
            throw new \RuntimeException("Required extension 'dom' seems to be missing.");
        }

        return $styleString;
    }