Writing XML with PHP

I’ve looked throught some tutorials and have found nothing good on Google or elsewhere.

My problem is that I’m in the prossess of making a full flash site that has a forum, an events page, a members page, etc. And when I want to list the top 3 events I’m using loadVars, which means I have to define numerous variables like title1, event1, etc. after their loaded from my mysql database.

This could be easily simplified if I could load events.php and it had the information displayed as an XML tree and I could use

events = new XML();
events.load(“events.php”);

But I coulden’t figure out how to quite do that with php’s DOM function. Since it only seems to be able to load an already made XML file and them manipulate it.
I want to make one and print it depending on my mysql info.

But if I were to just right it out it wouldn’t display the tags like I need for XML.

Does anyone have a good tutorial or know what I need to look at to figure this out.
Thanks in advance.