You'd generate the xml file in exactly the same way you'd generate an HTML file.
The only difference would be that before you output anything, it would pay to do
header('Content-Type: text/xml');
first.
Otherwise, like I said, the process is exactly the same.