Пример кода:
var data:Array = [
["apple", "orange", "banana"],
["dog", "cat", "monkey", "lion"],
["venus", "mars"]
];
var xml:XML = <xml />;
for (var i:int = 0; i < data.length; i++) {
var page:Array = data[i];
var pageNode:XML = <page />;
pageNode.@id = i;
xml.appendChild(pageNode);
for (var j:int = 0; j < page.length; j++) {
var item:String = page[j];
var itemNode:XML = <item />;
itemNode.@id = j;
pageNode.appendChild(itemNode);
itemNode.appendChild(item);
}
}
trace("XML:", xml.toString());
Выход:
XML: <xml>
<page id="0">
<item id="0">apple</item>
<item id="1">orange</item>
<item id="2">banana</item>
</page>
<page id="1">
<item id="0">dog</item>
<item id="1">cat</item>
<item id="2">monkey</item>
<item id="3">lion</item>
</page>
<page id="2">
<item id="0">venus</item>
<item id="1">mars</item>
</page>
</xml>