本文整理汇总了PHP中DOMElement::getDom方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement::getDom方法的具体用法?PHP DOMElement::getDom怎么用?PHP DOMElement::getDom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMElement
的用法示例。
在下文中一共展示了DOMElement::getDom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __wakeup
/**
* Unserialization handler; handles $this->_element being an instance of
* DOMElement or Horde_Xml_Element, or parses it as an XML string.
*/
public function __wakeup()
{
if ($this->_element instanceof DOMElement) {
return true;
}
if ($this->_element instanceof Horde_Xml_Element) {
$this->_element = $this->_element->getDom();
return true;
}
if ($this->_serialized) {
$this->_element = $this->_serialized;
$this->_serialized = null;
}
if (is_string($this->_element)) {
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
$extract = false;
if (substr($this->_element, 0, 5) != '<?xml') {
$extract = true;
$preamble = '<?xml version="1.0" encoding="UTF-8" ?><root ';
foreach (self::$_namespaces as $prefix => $nsUri) {
$preamble .= " xmlns:{$prefix}=\"{$nsUri}\"";
}
$preamble .= '>';
$this->_element = $preamble . $this->_element . '</root>';
}
$loaded = @$doc->loadXML($this->_element);
if (!$loaded) {
throw new Horde_Xml_Element_Exception('DOMDocument cannot parse XML: ', error_get_last());
}
if ($extract) {
$newDoc = new DOMDocument();
$this->_element = $newDoc->importNode($doc->documentElement->childNodes->item(0), true);
} else {
$this->_element = $doc->documentElement;
}
return true;
}
throw new InvalidArgumentException('Horde_Xml_Element initialization value must be a DOMElement, a Horde_Xml_Element, or a non-empty string; ' . (gettype($this->_element) == 'object' ? get_class($this->_element) : gettype($this->_element)) . ' given');
}