本文整理匯總了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');
}