Sending generated XML to a file

Hello there

I’ve been having a good look at the XML / PHP tutorial at

I’ve managed to customise the PHP to generate the XML just as I want it, but I would like to be able to export the data to an XML file for reading by a Flash object. Can anyone help me to add a bit to the end of the script that writes the data to an XML file, overwriting any existing data each time the script is run?

Many thanks in advance.