本文整理匯總了PHP中domDocument::loadhtml方法的典型用法代碼示例。如果您正苦於以下問題:PHP domDocument::loadhtml方法的具體用法?PHP domDocument::loadhtml怎麽用?PHP domDocument::loadhtml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類domDocument
的用法示例。
在下文中一共展示了domDocument::loadhtml方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: saveHtml
public function saveHtml($refresh = true)
{
if (extension_loaded('xml') and class_exists('DomXpath')) {
if (get_parent_class($this) === __CLASS__) {
$node = $this->node;
} elseif (get_parent_class($this) === false) {
$node = $this;
} else {
return false;
}
if (!is_a($node, jqmel)) {
return false;
}
if ($node->_length === false) {
return false;
}
$docm = jqm_use($node->_parentElement);
//$docm->__documentRaw = preg_replace('/\s+/',' ',$docm->__documentRaw);
$doc = $docm->_DOM;
if ($doc->doctype) {
$doc->removeChild($doc->doctype);
}
$k = key($this->_domId);
if ($refresh == true) {
$this->refresh();
$node->_attributes['data-dom-id'] = $k;
} else {
if ($this->_domId[$k] === NULL) {
$attr = $node->_attributes;
unset($attr['data-dom-id']);
$node->_attributes = $attr;
} else {
$node->_attributes['data-dom-id'] = $this->_domId[$k];
}
}
$newdoc = new domDocument();
$dom = $node->dom()->get();
$newdoc->loadhtml(mb_convert_encoding($dom->lastdom, 'HTML-ENTITIES', 'UTF-8'));
$newdoc->removeChild($newdoc->doctype);
$newdoc_get = $newdoc->getElementsByTagName($node->_name);
//Finder
$xpath = new DomXpath($doc);
$find = $xpath->query($node->_path);
if ($find->length > 0) {
$frag = $doc->importNode($newdoc_get->item(0), true);
if ($find->item(0)->parentNode) {
$find->item(0)->parentNode->replaceChild($frag, $find->item(0));
}
/* $output = $doc->saveHTML();
$hasHTML = (strip_tags($docm->__documentRaw,'<html>') !==$docm->__documentRaw);
if($hasHTML===false){
//Return just a partial html
$docm->__documentRaw = str_ireplace(array('<html>','<body>','</html>','</body>','<head>','</head>'),'',$output);
}else{
$docm->__documentRaw = $output;
} */
$node->_attributes['data-dom-id'] = $this->_domId[$k];
return $frag->getNodepath();
}
}
}