ID:               40359
 Updated by:       [EMAIL PROTECTED]
 Reported By:      gmtfn at yahoo dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         DOM XML related
 Operating System: Linux and Windows
 PHP Version:      5.2.0
 New Comment:

use saveXML instead of saveHTML and you get, what you expect (maybe
also try loadXML, instead of loadXML, depending on what's your input)

Besides that, it's not a PHP, but a libxml2 issue, since PHP only uses
the functions from there (and I assume, they do the correct thing
regarding whitespaces, html and the specs)

load/saveHTML should only be used, if you want to use HTML 4.0, for
xhtml, you're supposed to use the load/saveXML stuff.


Previous Comments:
------------------------------------------------------------------------

[2007-02-05 01:14:42] gmtfn at yahoo dot com

Your system changed my input. Before you test it, put everything
between opening and closing UL tags on one line.

------------------------------------------------------------------------

[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

Reply via email to