note 118655 added to class.domnode
| From: | zlk1214 at gmail dot com | Date: | Fri, 15 Jan 2016 13:07:07 +0000 |
| Subject: | note 118655 added to class.domnode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204685@lists.php.net to get a copy of this message | ||
A function that can set the inner HTML without encoding error. $html can be broken content such as
"<a ID=id20>ssss"
function setInnerHTML($node, $html) {
removeChildren($node);
if (empty($html)) {
return;
}
$doc = $node->ownerDocument;
$htmlclip = new DOMDocument();
$htmlclip->loadHTML('<meta http-equiv="Content-Type"
content="text/html;charset=utf-8"><div>' . $html .
'</div>');
$clipNode = $doc->importNode($htmlclip->documentElement->lastChild->firstChild,
true);
while ($item = $clipNode->firstChild) {
$node->appendChild($item);
}
}
----
Server IP: 72.52.91.14
Probable Submitter: 118.163.208.4
----
Manual Page -- http://php.net/manual/en/class.domnode.php
Edit -- https://master.php.net/note/edit/118655
Del: integrated -- https://master.php.net/note/delete/118655/integrated
Del: useless -- https://master.php.net/note/delete/118655/useless
Del: bad code -- https://master.php.net/note/delete/118655/bad+code
Del: spam -- https://master.php.net/note/delete/118655/spam
Del: non-english -- https://master.php.net/note/delete/118655/non-english
Del: in docs -- https://master.php.net/note/delete/118655/in+docs
Del: other reasons-- https://master.php.net/note/delete/118655
Reject -- https://master.php.net/note/reject/118655
Search -- https://master.php.net/manage/user-notes.php