php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72454 Allow to specify indentation width when DOMDocument::formatOutput = true
Submitted: 2016-06-20 07:01 UTC Modified: 2016-06-24 00:00 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: jonasschuermann at aol dot de Assigned:
Status: Open Package: DOM XML related
PHP Version: 7.0.7 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-06-20 07:01 UTC] 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();


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-24 00:00 UTC] cmb@php.net
-Summary: Allow to specify indentiation width when DOMDocument::formatOutput = true +Summary: Allow to specify indentation width when DOMDocument::formatOutput = true
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Sep 16 22:01:27 2019 UTC