è sufficente utilizzare w+ anzichè w per creare il file in automatico quando non esiste...

Codice PHP:
$file= fopen("test.xml", "w+");
$_xml ="<?xml version="1.0\" encoding=\"UTF-8\" ?>\r\n";  
$_xml .="<root>\r\n";    
$_xml .="\t<news>\r\n";  
$_xml .="\t\t<data>" $gg."/".$mm."/".$aa "</data>\r\n";
$_xml .="\t\t<testo_up>" $news "</testo_up>\r\n"$_xml .="\t\t<img>" $file "</img>\r\n";
$_xml .="\t\t<testo_down>" $news1 "</testo_down>\r\n"$_xml .="\t</news>\r\n";    $_xml .="</root>";  
fwrite($file$_xml);  
fclose($file);