Create xml with php
===

I have this php script from a file uploader. It is generating a correct xml file, but everytime I upload a new item it replaces the current nodes instead of adding to the "tree". Any ideas on how to do that?

Thank you in advance.

    <?php
    
    $todayDate = $_POST['todayDate'];
    $Name = $_POST['Name'];
    $Email = $_POST['Email'];
    $filename = $_FILES['Filedata']['name'];	
    $filetmpname = $_FILES['Filedata']['tmp_name'];	
    $fileType = $_FILES["Filedata"]["type"];
    $fileSizeMB = ($_FILES["Filedata"]["size"] / 1024 / 1000);
    
    move_uploaded_file($_FILES['Filedata']['tmp_name'], "images/".$filename);
    
    
    
    $xml = new XMLWriter;
    $xml->openMemory();
    $xml->startDocument( '1.0' , 'iso-8859-1' );
    $xml->startElement("galeria");
    $xml->writeElement("Name", $Name);
    $xml->writeElement("Email", $Email);
    $xml->endElement();
    //header( 'Content-type: text/xml' );
    //print $xml->outputMemory(true);
    $file = fopen('data.xml','w+');
    fwrite($file,$xml->outputMemory(true));
    fclose($file);
    
    
    
    ?>