Req #72454 [Opn->Wfx]: Allow to specify indentation width when DOMDocument::formatOutput = true
| From: | beberlei@php.net | Date: | Mon, 23 Sep 2019 19:09:21 +0000 |
| Subject: | Req #72454 [Opn->Wfx]: Allow to specify indentation width when DOMDocument::formatOutput = true | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222899@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72454&edit=1
ID: 72454
Updated by: beberlei@php.net
Reported by: jonasschuermann at aol dot de
Summary: Allow to specify indentation width when
DOMDocument::formatOutput = true
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: DOM XML related
PHP Version: 7.0.7
-Assigned To:
+Assigned To: beberlei
Block user comment: N
Private report: N
New Comment:
This is actually not exposed in a nice way to modify in libxml, the underlying library that does the
xml rendering in ext/dom. closing the ticket. sorry :(
Previous Comments:
------------------------------------------------------------------------
[2019-09-22 22:44:19] beberlei@php.net
This is technically possible if we add another option "formatOutputIndentSize" that
proxies to the libxml indent_size option.
------------------------------------------------------------------------
[2016-06-20 07:01:35] jonasschuermann at aol dot de
Description:
------------
I am using DOMDocument to pretty-print XML files:
$domDocument = new DomDocument();
$domDocument->preserveWhiteSpace = false;
$domDocument->formatOutput = true;
$domDocument->loadXML($uglyXml);
$prettyXml = $domDocument->saveXML();
The identiation width is hardcoded with 2 spaces. I would like to be able to specify a custom
identiation width, something like
$domDocument->indentWidth = 4;
Test script:
---------------
$domDocument = new DomDocument();
$domDocument->preserveWhiteSpace = false;
$domDocument->formatOutput = true;
$domDocument->indentWidth = 4;
$domDocument->loadXML($uglyXml);
$prettyXml = $domDocument->saveXML();
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72454&edit=1