|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31873 DOMDocument->preserveWhiteSpace not working correctly
Submitted: 2005-02-07 18:44 UTC Modified: 2005-02-09 12:50 UTC
From: becicka at aarongroup dot cz Assigned:
Status: Not a bug Package: *XML functions
PHP Version: 5.0.3 OS:
Private report: No CVE-ID: None
 [2005-02-07 18:44 UTC] becicka at aarongroup dot cz
$dom->saveXML() return:
<?xml version="1.0"?>

instead of: 
<?xml version="1.0"?><a><B><C/></B></a>

Reproduce code:
$dom = new DOMDocument;
$dom->preserveWhiteSpace = false;

$def = '
echo "<pre>";
echo htmlentities($dom->saveXML());
echo "</pre>";

Expected result:
$dom->saveXML() should return
<?xml version="1.0"?><a><B><C/></B></a>

Actual result:
<?xml version="1.0"?>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-07 19:18 UTC]
Works fine on my machine, as it returns:

<?xml version="1.0"?>

What version of libxml2 are you using? 2.6.x? Something earlier?
 [2005-02-08 08:53 UTC] becicka at aarongroup dot cz
DOM/XML  enabled  
DOM/XML API Version  20031129  
libxml Version  2.6.16  
HTML Support  enabled  
XPath Support  enabled  
XPointer Support  enabled  
Schema Support  enabled  
RelaxNG Support  enabled
 [2005-02-08 12:00 UTC]
Do you happen to be running windows? - this looks like a libxml bug using windows cr/lf endings to me but would like to be sure before bogusing this and pushing it off to the libxml list.
 [2005-02-08 12:24 UTC] becicka at aarongroup dot cz
There are the same situation under windows xp. It doesn't work properly.
 [2005-02-09 09:28 UTC]
Just tested with the test-script saved in "Win" Format on OS X with libxml2-2.6.16. Then this bug is reproducable. If it's saved with unix line endings, it does the job as expected.

 [2005-02-09 12:50 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

libxml bug. reporting it there
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Nov 27 14:03:20 2021 UTC