#40359 [NEW]: DOMDocument's saveHTML() ignores formatOutput property

From: Date: Mon, 05 Feb 2007 01:09:35 +0000
Subject: #40359 [NEW]: DOMDocument's saveHTML() ignores formatOutput property
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-108397@lists.php.net to get a copy of this message
From: gmtfn at yahoo dot com Operating system: Linux and Windows PHP version: 5.2.0 PHP Bug Type: DOM XML related Bug description: DOMDocument's saveHTML() ignores formatOutput property 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 bug report at http://bugs.php.net/?id=40359&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40359&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40359&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40359&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40359&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40359&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40359&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40359&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40359&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40359&r=support Expected behavior: http://bugs.php.net/fix.php?id=40359&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40359&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40359&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40359&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40359&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40359&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40359&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40359&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40359&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40359&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40359&r=mysqlcfg

« previous php.bugs (#108397) next »