title: Writing xml with php
body: <p>I don't know where my error comes from, i am new to xml and i need some help.
  I want to write an xml file using php. I have the following php code:</p>
  
  <pre><code>&lt;?php 
   $xml = array(); 
   $xml [] = array( 
   'error' =&gt; 'ERROR_ID'
    ); 
  
   $doc = new DOMDocument(); 
   $doc-&gt;formatOutput = true; 
  
   $r = $doc-&gt;createElement( "xml" ); 
   $doc-&gt;appendChild( $r ); 
  
   $parameters = $doc-&gt;createElement( "parameters" );    
    $error = $doc-&gt;createElement( "error" ); 
   $error-&gt;appendChild( 
   $doc-&gt;createTextNode( $xml['error'] ) 
   ); 
   $parameters-&gt;appendChild( $error ); 
  
  
   $r-&gt;appendChild( $parameters ); 
  
  
   echo $doc-&gt;saveXML(); 
   $doc-&gt;save("write.xml") 
   ?&gt;
  </code></pre>
  
  <p>My xml file should look like this:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xml&gt;
    &lt;parameters&gt;
      &lt;error&gt;ERROR_ID&lt;/error&gt;
    &lt;/parameters&gt;
  &lt;/xml&gt;
  </code></pre>
  
  <p>but the ERROR_ID text node doesn't show up in the file.What went wrong?</p>