From: k...@php.net Operating system: Mac OS X 10.5.7 PHP version: 5.3CVS-2009-06-09 (CVS) PHP Bug Type: DOM XML related Bug description: formatOutput does not work with saveHTML
Description: ------------ While writing test cases on Oslo TestFest 2009 I just found that the $dom->formatOutput does not work with $dom->saveHTML() (even though it seems to have been resolved here: http://bugs.php.net/bug.php?id=35673) xmllint says: $ xmllint --format --html output.html <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>This is the title</title> </head></html> so according to Hannes here this seems to be a bug in PHP 5.3 (may be that it's fixed i HEAD but not backported?). Reproduce code: --------------- <?php $doc = new DOMDocument('1.0'); $doc->formatOutput = true; $root = $doc->createElement('html'); $root = $doc->appendChild($root); $head = $doc->createElement('head'); $head = $root->appendChild($head); $title = $doc->createElement('title'); $title = $head->appendChild($title); $text = $doc->createTextNode('This is the title'); $text = $title->appendChild($text); echo $doc->saveHTML(); ?> Expected result: ---------------- <html> <head> <title>This is the title</title> </head> </html> Actual result: -------------- <html><head><title>This is the title</title></head></html> -- Edit bug report at http://bugs.php.net/?id=48509&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48509&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48509&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48509&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48509&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48509&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48509&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48509&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48509&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48509&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48509&r=support Expected behavior: http://bugs.php.net/fix.php?id=48509&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48509&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48509&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48509&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48509&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48509&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48509&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48509&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48509&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48509&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48509&r=mysqlcfg