Save XML from textarea into an xml file?

smartipants

New Member
I have a textarea in which I prints all my xml like this:\[code\]<form method="post" action=""><textarea id="codeTextarea" name="thisxml" cols="100" rows="36"><?php$xml = new DOMDocument();$xml->formatOutput = true;$xml->preserveWhiteSpace = false;$xml->loadXML('<?xml version="1.0" encoding="ISO-8859-1"?><data> <game id="103478"> <opponent>Peter</opponent> <oppid>4</oppid> <lastdraw>0</lastdraw> </game> <game id="103479"> <opponent>Peter</opponent> <oppid>4</oppid> <lastdraw>2</lastdraw> </game> <game id="103483"> <opponent>James</opponent> <oppid>47</oppid> <lastdraw>2</lastdraw> </game></data>');echo htmlspecialchars($xml->saveXML()); ?></textarea>\[/code\]I then on submit want to create/update the file with the new xml but all I get in the new xml document is this:\[code\]<?xml version="1.0"?>\[/code\]I try to save the xml like this with PHP:\[code\]$myFile = 'TEST.xml';$fh = fopen($myFile, 'w') or die("can't open file");$stringData = http://stackoverflow.com/questions/12676993/htmlspecialchars($_POST['thisxml']);fwrite($fh, $stringData);fclose($fh);\[/code\]Can somebody please tell me what I am doing wrong? Thanks in advance ;-)
 
Back
Top