Req #72454 [Com]: Allow to specify indentation width when DOMDocument::formatOutput = true
| From: | beberlei@php.net | Date: | Sun, 22 Sep 2019 22:44:19 +0000 |
| Subject: | Req #72454 [Com]: Allow to specify indentation width when DOMDocument::formatOutput = true | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222880@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
Comment by: beberlei@php.net
Reported by: jonasschuermann at aol dot de
Summary: Allow to specify indentation width when
DOMDocument::formatOutput = true
Status: Open
Type: Feature/Change Request
Package: DOM XML related
PHP Version: 7.0.7
Block user comment: N
Private report: N
New Comment:
This is technically possible if we add another option "formatOutputIndentSize" that
proxies to the libxml indent_size option.
Previous Comments:
------------------------------------------------------------------------
[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