changeset 2320:ae69e61a6b76

#46 PHP server now beautifies incoming XMLs. Could solve future #25 errors.
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Fri, 29 Apr 2016 16:40:13 +0100
parents 6897339ac651
children 472412fab354 1f4aa23ae847
files php/save.php
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/php/save.php	Fri Apr 29 16:26:34 2016 +0100
+++ b/php/save.php	Fri Apr 29 16:40:13 2016 +0100
@@ -5,6 +5,11 @@
 	$postText = file_get_contents('php://input');
     $file_key = $_GET['key'];
     $filename = "../saves/save-".$file_key.".xml";
+    $doc = new DOMDocument;
+    $doc->preserveWhiteSpace = false;
+    $doc->formatOutput = true;
+    $doc->loadXML($postText);
+    $postText = $doc->saveXML();
 	$fileHandle = fopen($filename, 'w');
 	if ($fileHandle == FALSE)
 	{