Writing XML

I have to write some xml and save it to a file in AIR, and I’ve realised I’m not very good at it.
My data is currently stored in an ArrayCollection of Product Objects, and needs to be serialised in the format:

<data>
    <product page="1" id="product_1" pid="81100"/>
    <product page="1" id="product_2" pid="81109"/>
    <product page="1" id="product_3" pid="81252"/>
    <product page="1" id="product_4" pid="81194"/>
</data>

At the moment, I have the following code, but it spits trying to create the product attributes.

var newXmlString:String = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
                var newXml:XML = new XML();
                var data:XMLList = new XMLList(<data></data>)
                newXml.appendChild(data);
                for(var i:int=0;i<prodGroup.length;i++){
                    var newNode:XMLNode = new XMLNode(1,<product/>);
                    newNode.@['page'] = prodGroup*.page;
                    newNode.@['id'] = prodGroup*.id;
                    newNode.@['pid'] = prodGroup*.pid;
                    newNode.@['caption'] = prodGroup*.caption;
                    newXml.data.appendChild(newNode);
                    
                }
                newXmlString += newXml.toXMLString();
                saveData(newXmlString);