Create xml from flash array

Hi all,

I have array that contains other arrays, and I need to create xml from this structure.

This is just an example of the osrt of array I have.


var cars = new Array();
var car1 = new Array()
var car2 = new Array()
var car3 = new Array()
car1.make = "ford"
car1.model = "capri"
car1.car_color = "red"
cars.push(car1)
car2.make = "citroen"
car2.model = "c2"
car2.car_color = "blue"
cars.push(car2)
car3.make = "audi"
car3.model = "coupe"
car3.car_color = "black"
cars.push(car3)
trace(cars[0].make)

and this is the sort of xml I was tring to get from it.


<cars>
        <car1>
           <make>ford</make>
           <model>capri</model>
           <color>red</color>
        <car1>
        <car2>
           <make>citroen</make>
           <model>c2</model>
           <color>blue</color>
        </car2>
        …

</cars>