note 85165 added to function.dom-domdocument-savehtml
| From: | mathbblogsdaughtcalm at osu1 dot php dot net | Date: | Mon, 18 Aug 2008 15:41:41 +0000 |
| Subject: | note 85165 added to function.dom-domdocument-savehtml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-143590@lists.php.net to get a copy of this message | ||
This method, as of 5.2.6, will automatically add <html><body> and <!DOCTYPE> tags
to the document if they are missing, without asking whether you want them. In my application, I
needed to use the DOM methods to manipulate just a fragment of html, so these tags were rather
unhelpful.
Here's a simple hack to remove them in case, like me, all you wanted to do was perform a few
operations on an HTML fragment.
$html_fragment = preg_replace('/^<!DOCTYPE.+?>/', '', str_replace(
array('<html>', '</html>', '<body>',
'</body>'), array('', '', '', ''),
$dom->saveHTML()));
----
Server IP: 64.71.164.2
Probable Submitter: 98.172.154.66
----
Manual Page -- http://www.php.net/manual/en/function.dom-domdocument-savehtml.php
Edit -- https://master.php.net/note/edit/85165
Del: integrated -- https://master.php.net/note/delete/85165/integrated
Del: useless -- https://master.php.net/note/delete/85165/useless
Del: bad code -- https://master.php.net/note/delete/85165/bad+code
Del: spam -- https://master.php.net/note/delete/85165/spam
Del: non-english -- https://master.php.net/note/delete/85165/non-english
Del: in docs -- https://master.php.net/note/delete/85165/in+docs
Del: other reasons-- https://master.php.net/note/delete/85165
Reject -- https://master.php.net/note/reject/85165
Search -- https://master.php.net/manage/user-notes.php