Para que puedas descargar el resultado de un script php es necesario que lo guardes en un archivo de esta manera:
Código PHP:
$file=fopen("xml/".$nombreXML.".xml","w") or die("Problemas en la creacion");//En esta linea lo que hace PHP es crear el archivo, si ya existe lo sobreescribe
fputs($file,$resultadoPHP);//En esta linea abre el archivo creado anteriormente e ingresa el resultado de tu script PHP
fclose($file);//Finalmente lo cierra
Para descargar el archivo es necesario este script
Código PHP:
$ruta="xml/".$nombreXML.".xml";
header ("Content-Disposition: attachment; filename=".$ruta);
header ("Content-Type: application/octet-stream");
header ("Content-Length: ".filesize($ruta));
readfile($ruta);
Espero que sea de tu ayuda