# HG changeset patch # User Nicholas Jillings # Date 1484827706 0 # Node ID 3986de98f04a6d67d9a9aed42e4524f56cd5ad44 # Parent 6324f500beb38666ae3c2e575c2f9b609c9e8910 Use DOMDocument diff -r 6324f500beb3 -r 3986de98f04a php/requestKey.php --- a/php/requestKey.php Thu Jan 19 11:27:29 2017 +0000 +++ b/php/requestKey.php Thu Jan 19 12:08:26 2017 +0000 @@ -55,16 +55,20 @@ fclose($fileHandle); // TODO: // Generate the XML Base file and save it -$doc_struct = new SimpleXMLElement(''); -$doc_struct->addAttribute("key",$key); +$doc_struct = new DOMDocument; +$doc_struct->preserveWhiteSpace = false; +$doc_struct->formatOutput = true; +$doc_struct->loadXML(""); // Add the root if (file_exists($testURL)) { - $test_proto = simplexml_load_string(file_get_contents($testURL, FILE_TEXT)); - $doc_struct->addChild($test_proto); + $test_proto = new DOMDocument; + $test_proto->loadXML(file_get_contents($testURL, FILE_TEXT)); + $test_proto = $doc_struct->importNode($test_proto, true); + $doc_struct->documentElement->appendChild($test_proto); } // Add start time // Add IP Address information // Save the file -$doc_struct->asXML($filename); +$newdoc->saveXML($filename); echo "OK".$key.""; ?>