Хорошо вставка XML в Array имеет различные преимущества, как указано в комментариях выше. Как вы получите Nested Array для образца XML
<mynode4 swf="node4.swf" htmlpage="">
<subheading1 swf="L4_s1.swf" htmlpage="L4_1.htm">Work Hard</subheading1>
<subheading2 swf="L4_s2.swf" htmlpage="L4_2.htm">karachi</subheading2>
<subheading3 swf="L4_s3.swf" htmlpage="L4_3.htm">Newyork City.</subheading3>
</mynode4>
<mynode5 swf="five.swf" htmlpage="">Here is the Test for node 5</mynode5>
<mynode6 swf="six.swf" htmlpage="">Last node accessed</mynode6>
var uLoader: URLLoader = new URLLoader () uLoader.addEventListener (Event.COMPLETE, onXMLLoaded) uLoader.load (новый URLRequest ("xmldata.xml"))
открытая функция onXMLLoaded (событие: событие): void
var loader:URLLoader = URLLoader(event.target);
var root1:XML = new XML(loader.data);
var showChilds:XMLList = root1.children();
var nodes_names2 :Array = new Array();
var nodes_swf2 :Array = new Array();
var nodes_values2 :Array = new Array();
var nodes_pages2 :Array = new Array();
var take_items:Array = recursiveXML(showChilds,nodes_names2,nodes_swf2,nodes_values2,nodes_pages2,0);
this.nodes_names2 = take_items[0];
this.nodes_swf2 = take_items[1];
this.nodes_values2 = take_items[2];
this.nodes_pages2 = take_items[3];
trace( nodes_names2);
trace( nodes_swf2);
trace( nodes_values2);
trace( nodes_pages2);
}
открытая функция recursiveXML (showChilds: XMLList, node_names: Array, node_swf: Array, node_values: Array, node_pages: Array, count: int): Array {
for each (var eachChild:XML in showChilds)
{
if(eachChild.hasComplexContent())
{
nodes_names[count] = new Array((eachChild.children().length()))
nodes_swf[count] = new Array((eachChild.children().length()))
nodes_values[count] = new Array((eachChild.children().length()))
nodes_pages[count] = new Array((eachChild.children().length()))
nodes_names[count][0] = eachChild.name()
nodes_swf[count][0] = eachChild.attribute("swf");
nodes_values[count][0] = "";
nodes_pages[count][0] = "";
var showChilds:XMLList = eachChild.children();
var take_items:Array = recursiveXML(showChilds,nodes_names[count],nodes_swf[count],nodes_values[count],nodes_pages[count] , 1);
nodes_names[count] = take_items[0];
nodes_swf[count] = take_items[1];
nodes_values[count] = take_items[2];
nodes_pages[count] = take_items[3];
count++;
}
else
{
nodes_names[count] = eachChild.name();
nodes_swf[count] = eachChild.attribute("swf");
nodes_pages[count] = eachChild.attribute("htmlpage");
nodes_values[count] = eachChild.text();
count++;
}
}
var _items:Array = new Array( nodes_names, nodes_swf,nodes_values,nodes_pages);
return _items;
}