|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27783 DomDocument::formatOutput = true doesn' work with loaded files.
Submitted: 2004-03-30 15:37 UTC Modified: 2004-03-31 12:16 UTC
From: manuel dot hesse at xplib dot de Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.0.0RC1 OS: linux fedora core 1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: manuel dot hesse at xplib dot de
New email:
PHP Version: OS:


 [2004-03-30 15:37 UTC] manuel dot hesse at xplib dot de
The formatOutput feature doesn' t work with documents, that use DomDocument::load() for creation. But it works with in memory DOM Documents.

Reproduce code:
$dom  = new DomDocument();
$file = "/path/to/file/dom.xml";
if (file_exists($file)) {
} else {

printf("<pre>%s</pre>", htmlentities($dom->saveXML()));


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-31 12:16 UTC]
works fine for me

loading from file also creates whitespaced nodes within the document. use $dom->preserveWhiteSpace = FALSE; before loading then $dom->formatOutput = TRUE; before the save and the results will be the same whether loaded from file or memory
 [2011-04-25 09:23 UTC] bacurastone at ymail dot com
for thanks. it's help full
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jun 15 13:01:24 2021 UTC