note 88864 added to domdocument.loadhtml
| From: | Errol at osu1 dot php dot net | Date: | Wed, 11 Feb 2009 16:05:13 +0000 |
| Subject: | note 88864 added to domdocument.loadhtml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-150490@lists.php.net to get a copy of this message | ||
It should be noted that when any text is provided within the body tag
outside of a containing element, the DOMDocument will encapsulate that
text into a paragraph tag (<p>).
For example:
$doc = new DOMDocument();
$doc->loadHTML("<html><body>Test<br><div>Text</div></body></html>");
echo $doc->saveHTML();
will yield:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
<p>Test<br></p>
<div>Text</div>
</body></html>
while:
$doc = new DOMDocument();
$doc->loadHTML(
"<html><body><i>Test</i><br><div>Text</div></body></html>");
echo $doc->saveHTML();
will yield:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body>
<i>Test</i><br><div>Text</div>
</body></html>
----
Server IP: 64.71.164.2
Probable Submitter: 130.74.94.200
----
Manual Page -- http://www.php.net/manual/en/domdocument.loadhtml.php
Edit -- https://master.php.net/note/edit/88864
Del: integrated -- https://master.php.net/note/delete/88864/integrated
Del: useless -- https://master.php.net/note/delete/88864/useless
Del: bad code -- https://master.php.net/note/delete/88864/bad+code
Del: spam -- https://master.php.net/note/delete/88864/spam
Del: non-english -- https://master.php.net/note/delete/88864/non-english
Del: in docs -- https://master.php.net/note/delete/88864/in+docs
Del: other reasons-- https://master.php.net/note/delete/88864
Reject -- https://master.php.net/note/reject/88864
Search -- https://master.php.net/manage/user-notes.php