Risolto così:
Codice PHP:
<?php
header ("content-type: text/xml");
include("connessione.php");
$sql="SELECT * FROM `categoria` ORDER BY `id_categoria` ASC";
$result = mysql_query($sql) or die ("Errore query: ".mysql_query($sql));
$xml = '<gallery title="Modula Gioielli" thumbDir="http://'.$_SERVER['SERVER_NAME'].'/images/" imageDir="http://'.$_SERVER['SERVER_NAME'].'/images/" random="true">';
while($category = mysql_fetch_assoc($result)){
$xml .= '<category name="'.$category['nome'].'">';
$result2 = mysql_query("SELECT * FROM `immagine` WHERE `id_categoria` = '".$category['id_categoria']."' ORDER BY `id_immagine` ASC");
while($image = mysql_fetch_assoc($result2)){
$xml .= "<image>";
$xml .= "<date>".$image['data']."</date>";
$xml .= "<title>".$image['titolo']."</title>";
$xml .= "<desc>".$image['descrizione']."</desc>";
$xml .= "<thumb>".$image['path']."</thumb>";
$xml .= "<img>".$image['path']."</img>";
$xml .= "</image>";
}
$xml .= "</category>";
}
$xml .= '</gallery>';
$XMLFile = fopen("gallery.xml","w") or die("ERRORE: Non posso aprire il file!");
fwrite($XMLFile, $xml);
fclose($XMLFile);
?>
;
Grazie a tutti!