#40359 [Opn]: DOMDocument's saveHTML() ignores formatOutput property
| From: | gmtfn at yahoo dot com | Date: | Mon, 05 Feb 2007 01:14:43 +0000 |
| Subject: | #40359 [Opn]: DOMDocument's saveHTML() ignores formatOutput property | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-108398@lists.php.net to get a copy of this message | ||
ID: 40359
User updated by: gmtfn at yahoo dot com
Reported By: gmtfn at yahoo dot com
Status: Open
Bug Type: DOM XML related
Operating System: Linux and Windows
PHP Version: 5.2.0
New Comment:
Your system changed my input. Before you test it, put everything
between opening and closing UL tags on one line.
Previous Comments:
------------------------------------------------------------------------
[2007-02-05 01:09:35] gmtfn at yahoo dot com
Description:
------------
The saveHTML() method of DOMDocument reformats input HTML contents
(from an HTML file or a string in a PHP file) despite that formatOutput
property is set to false.
Setting preserveWhiteSpace to true or false before or after loading the
HTML input doesn't seem to make a difference.
This may not seem important, but it breaks a third party menu software
I am using on Mozilla based browsers.
I've tried this with PHP 5.2 on Linux and PHP 5.1.x on Windows, with
the same results.
Reproduce code:
---------------
<?php
$myhtml = <<<EOF
<html>
<body>
<ul><li><a href="http://site.com">site</a></li><li><a
href="http://site.com">another
site</a><ul><li><a
href="http://site.com">third
site</a></li></ul></li></ul>
</body>
</html>
EOF;
$doc = new DOMDocument();
$doc->loadHTML($myhtml);
$doc->formatOutput = false;
echo $doc->saveHTML();
?>
Expected result:
----------------
I expected to see NO changed at all done to the input HTML. That's what
the "formatOutput = false" is for, isn't it?
By the way, setting this property to true doesn't seem to produce
anything different from what happens the property is set to false.
Actual result:
--------------
It reformats some fragments but leaves others in tact. Less important
(for me) changes are: body and html opening and closing tags are put on
2 lines even though in the input they occupy 4 lines. But the important
changes are:
the anchor tag is moved on a new line if it is a part of a <LI> that
contains an <UL> as well. See the code: the second <a> element is move
to a new line, away from its parent <LI>.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40359&edit=1