# AS3 , Flex tree control

**URL:** <https://forum.kirupa.com/t/as3-flex-tree-control/257646>\
**Category:** flash\
**Created:** [April 15, 2008, 11:27pm UTC](https://forum.kirupa.com/t/as3-flex-tree-control/257646 "2008-04-15T23:27:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ednasgoldfishuk](https://avatars.discourse-cdn.com/v4/letter/e/f6c823/32.png) [@ednasgoldfishuk](https://forum.kirupa.com/u/ednasgoldfishuk)\
**Post date:** [April 15, 2008, 11:27pm UTC](https://forum.kirupa.com/t/as3-flex-tree-control/257646/1 "2008-04-15T23:27:18Z")

</div>

Im relatively new to AS3 and Flex but here is my problem, at the moment that I am populating a tree in flex from an XML source, my problem is that the tree displays all child nodes of the XML passed to it, and I want it only to display the top node, I have tried using the delete method however I need the children of the XML for other functions, so I thought to create a new XMLList but it also deletes from the original XMLList now aswell? My ideal solution would be a way of selecting the top node for the tree but leaving the XML dataProvider intact, is this possible? Ive spent 2 days trying to find a solution and havent found anything so far?

```
    var node2:XML = XML(item);
    var strLabel:String;
    if (node2.@NavigationItemType==2) {
        strLabel = node2.@Caption;
     }
     return strLabel;

```

above returns the children of the top node with a blank caption, but you can still expand the tree with invisible items

```
    var i:int = 0;
    var j:int = mapTreeNavXML2.length;
    for (i=0;i&lt;j;i++) {
        delete mapTreeNavXML2*.NavigationItem.NavigationItem;
    }

```

and above is what i was using to remove the nodes but removes from my original instance of the xml ‘mapTreeNavXML’, any help on this would be definately appreciated so much.  
Thanks
