I have some Data Xml..
<main>
<TabNavigator x="27" y="11" width="455" height="376" id="gh" backgroundColor="#A4B6E9">
<NavigatorContent width="100%" height="100%" label="Client" id="clientTab"></NavigatorContent>
<NavigatorContent width="100%" height="100%" label="Admin" id="adminTab"></NavigatorContent></TabNavigator>
<TitleWindow x="521" y="84" width="377" height="234">
<DataGrid x="0" y="0" width="375" height="163" borderVisible="true" id="details">
<columns>
<ArrayList>
<GridColumn dataField="Name" id="arrayName"/><GridColumn dataField="Address" headerText="Address"/>
<GridColumn dataField="Phone_Number" headerText="Phone_Number"/>
</ArrayList>
</columns>
</DataGrid>
<Button x="139" y="167" height="28" label="Export"/>
</TitleWindow>
</main>
I use following code for retrieving the child names of given XML..
private function urlLdr_complete(event:Event):void{
var xmlData:XML=new XML(URLLoader(event.currentTarget).data);
for each (var t:XML in xmlData.children())
{
Alert.show(t.Name);
}
But I only get 2 children(TabNavigator and TitleWindow).How do I get the other children in each parent node? I want separate children for each parent. How can I get it?
You need to use a recursive function to walk down the tree. Using trace() instead of alert():
Or, use the E4X descendants() function:
Both should produce identical outcomes:
I haven’t tested but I would expect the built-in descendants() function to be more efficient.