|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74492 XMLWriter adds indent between mixed child nodes.
Submitted: 2017-04-23 10:58 UTC Modified: 2020-10-27 13:27 UTC
From: Assigned: cmb (profile)
Status: Closed Package: XML Writer
PHP Version: 7.1.4 OS:
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:
New email:
PHP Version: OS:


 [2017-04-23 10:58 UTC]
XMLWriter adds the defined indent between mixed child nodes. This will change the meaning if the text nodes do not contain leading/trailing whitespaces.

This does not happen if the indent is set to zero.

Test script:
$_ = new XMLWriter();

$_->writeElement('a', 'element');

echo $_->outputMemory();

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

Actual result:
<?xml version="1.0"?>
<p>before <a>element</a>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-04-02 22:05 UTC]
-Status: Open +Status: Analyzed
 [2018-04-02 22:05 UTC]
ext/xmlwriter is a rather thin layer over libxml2's xmlwriter
module[1], and this is the way that xmlTextWriterSetIndent() works
(currently). It might be worthwhile to report this issue
upstream[2], but pretty printing might better be left to
specialized tools, anyway.

In my opinion, it is best to make this a documentation issue, and
to convey that ::setIndent() is not necessarily suitable for mixed

By the way, XMLWriter::setIndent() expects a boolean argument, not
an integer.

[1] <>
[2] <>
 [2018-04-02 22:05 UTC]
-Type: Bug +Type: Documentation Problem
 [2020-10-27 13:27 UTC]
-Assigned To: +Assigned To: cmb
 [2020-10-27 13:30 UTC]
Automatic comment on behalf of cmb
Log: Fix #74492: XMLWriter adds indent between mixed child nodes
 [2020-10-27 13:30 UTC]
-Status: Analyzed +Status: Closed
 [2020-10-27 19:25 UTC]
Automatic comment on behalf of mumumu
Log: Fix #74492: XMLWriter adds indent between mixed child nodes / Remove erroneous notes
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Oct 31 12:01:23 2020 UTC