Flash TO XML

I’m creating a simple chat with flash with uses xml to store the messages.
But how can I send the variable msg from flash into a xml document?

If the xml-file looks like this:


<?xml version="1.0" encoding="iso-8859-1"?>
<messages>
</messages>

and I want to add the var newMsg inside the messages-tag, as the LAST msg-tag:

[AS]
newMsg = “<msg>Message text here</msg>”;
[/AS]

How should I do?

Thanks
Kalliban