php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23726 dump_file formatting option appears to be broken
Submitted: 2003-05-20 18:19 UTC Modified: 2003-05-27 12:01 UTC
From: bharris at spro dot net Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 4.3.2RC2 OS: Red Hat 8.0 (x86)
Private report: No CVE-ID: None
 [2003-05-20 18:19 UTC] bharris at spro dot net
Using 4.3.2RC2 dump_file such as:

$filesize = $dom->dump_file($filename, false, true);
OR
$filesize = $dom->dump_file($filename, 0, 1);

Does not nicely format the ouput but places it without whitespace.

However (peculiar) using
$filesize = $dom->dump_file($filename, false, 2);

DOES nicely format the output (however, it places additional spaces in already nicely formatted content)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-26 06:16 UTC] rrichards@php.net
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 http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

This behavior is from libxml and is based upon the structure of the tree you are trying to output. The undocumented feature of passing in a value other than 0 or 1 as the format paramter causes libxml to ignore its rules and format everything, though it possibly may produce an error.
 [2003-05-27 10:31 UTC] bharris at spro dot net
I need to clarify that for my system:
$filesize = $dom->dump_file($filename, false, false);
does the exact same thing as
$filesize = $dom->dump_file($filename, false, true);
which is to NOT format the output and is contrary to what has worked for me in the past and what the documentation states.
Are you saying that the problem lies in my libxml (i.e. this is a straight through call to the libxml API)?
 [2003-05-27 12:01 UTC] rrichards@php.net
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 http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

yes, this is a straight call to xmlSaveFormatFile if sending in the format flag, which your call would translate to xmlSaveFormatFile($filename, docp, 1) or xmlSaveFormatFile($filename, docp, 2). Within the xmlNodeDumpOutput (2.4.x libs) there are explicit checks for format == 1, so sending in a 2 bypass these checks. I believe it is not recommened to send in anything other than a 1 or a 0 as it can cause bad output. Also note that the output routines have been enhanced in newer versions of libxml so what may have worked in the past may not produce the same results anymore.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Nov 24 07:01:24 2020 UTC