views:

40

answers:

2

I have xml files with many children and then further more children.

like

<level1>
<child id=1 > <nodes....> </child1>
<child id=2 > <nodes....> </child1>
<child id=3 > <nodes....> </child1>
<child id=4 > <nodes....> </child1>
</level1>

Is it possible to get the children nodes of child with id = 1 in AS3

A: 

I don't have time for a detailed answer right now, but read up on e4x, which allows you to do what you require. I'll try and post an example later.

Ben Hughes
+1  A: 

Yes it s possible using filter function on xml:

var xml:XML=<level1>
<child id="1" > <nodes>1</nodes> </child>
<child id="2" > <nodes>2</nodes> </child>
<child id="3" > <nodes>3</nodes> </child>
<child id="4" > <nodes>4</nodes> </child>
</level1>;

// list of children with id=1
var xl:XMLList=xml.child.(@id=="1"); //<== here filter xml based on attribute "id"
for each (var node:XML in xl){
  trace(node.toString());
}
Patrick