Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOMDocument.saveXML() output not pretty #6034

Closed
niedzielski opened this issue Aug 18, 2015 · 2 comments
Closed

DOMDocument.saveXML() output not pretty #6034

niedzielski opened this issue Aug 18, 2015 · 2 comments

Comments

@niedzielski
Copy link

We use SimpleXMLElement to build Android string translations which we output to a file[0]:

$dom = new DOMDocument( '1.0' );
$dom->formatOutput = true;
$dom->loadXML( $writer->asXML() );
echo $dom->saveXML();

In 3.6.5+dfsg1-1+wm1, this produced nice XML. e.g.:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string name="key" fuzzy="true">value</string>
  <string name="anotherkey">anothervalue</string>
</resources>

In 3.8.1, all the newlines and whitespace are stripped to produce a minified but difficult to read output:

<?xml version="1.0" encoding="utf-8"?>
<resources><string name="key" fuzzy="true">value</string><string name="anotherkey">anothervalue</string></resources>

We're currently tracking this issue for translatewiki.net and the Wikipedia Android app here[1].

[0] Full source example here: https://3v4l.org/OjDaB
[1] https://phabricator.wikimedia.org/T109402

@paulbiss
Copy link
Contributor

The formatOutput setting is getting cleared by the call to loadXML. I'll put up a fix for this.

@niedzielski
Copy link
Author

Thanks, @paulbiss! I've updated our Phabricator ticket[0].

[0] https://phabricator.wikimedia.org/T109402

paulbiss added a commit that referenced this issue Aug 28, 2015
Summary: When loadXML or loadHTML is called, the DOMDocument should preserve any existing
settings.

Fixes #6034
Fixes #5412

Reviewed By: @jwatzman

Differential Revision: D2357973
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants