io ho creaton file Utenti.xml vuoto e poi ho creato una pagina UtentiXML.php ti posto il codice della pagina php

Codice PHP:
<?php
//include("condb.php"); // per ora non serve perche il file è incluso in Index.php
$query "SELECT * FROM mex;";
$ris mysql_query($query,$con) or die("Errore nella query: " mysql_error());

$head "<?xml version='1.0' encoding='iso-8859-1'?>
    <!DOCTYPE Annunci SYSTEM 'StileXML.dtd'>
    <meta name='AUTHOR' content='MWI - MarkWeb Informatica -'>
<link rel='stylesheet' type='text/css' media='screen' href='StyleMWI.css'>
    
    <Annunci>
"
;
$foot "</Annunci>";
$nomefile="Utenti.xml";
// apri il file in scrittura
$fp fopen($nomefile,"r+") or
          die(
"Spiacente, non posso aprire il file");

// scrivi l'head
fwrite($fp$head."\n");
while(
$riga mysql_fetch_array($ris)) {
 if (
$riga['Sesso']=='Uomo'
    { 
      
$testo "<Uomo>
"
;
      
$testo7"<sesso>$riga[Sesso]</sesso>
"
;
      
$testo1"<Nick>$riga[Nick]</Nick>
"
;
      
$testo2 "<Mail>$riga[Mail]</Mail>
"

      
$testo3"<www>$riga[www]</www>
"
;
      
$testo4"<Testo>$riga[Testo]</Testo>
"
;
      
$testo5"<Orientamento>$riga[Orientamento]</Orientamento>
"
;
      
$testo6 "</Uomo>
"
;
      
$txt=$testo."\n     ".$testo7."\n     ".$testo1."\n     ".$testo2."\n     ".$testo3."\n     ".$testo4."\n     ".$testo5."\n".$testo6;
    }
  else 
    {
      
$testo "<Donna>
"
;
      
$testo7"<sesso>$riga[Sesso]</sesso>
"
;
      
$testo1"<Nick>$riga[Nick]</Nick>
"
;
      
$testo2 "<Mail>$riga[Mail]</Mail>
"

      
$testo3"<www>$riga[www]</www>
"
;
      
$testo4"<Testo>$riga[Testo]</Testo>
"
;
      
$testo5"<Orientamento>$riga[Orientamento]</Orientamento>
"
;
      
$testo6 "</Donna>
"
;
      
$txt=$testo."\n     ".$testo7."\n     ".$testo1."\n     ".$testo2."\n     ".$testo3."\n     ".$testo4."\n     ".$testo5."\n".$testo6;
    }
  
// scrivi la riga
  
fwrite($fp$txt."\n");
}
// scrivi il foot
fwrite($fp$foot."\n");
$leggifile fread($fpfilesize($nomefile));
echo 
"File Utenti.xml creato "; echo $leggifile;
fclose($fp);
?>
Ricordati che il file utenti.xml deve esistere anche se vuoto