<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/11/29/toggling-a-tree-controls-root-node-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white" viewSourceURL="srcview/index.html">
    
    <mx:XML id="xmlDP">
        <root label="root">
            <child1 label="child1a">
                <child2 label="child2a" />
                <child2 label="child2b">
                    <child3 label="child3b" />
                </child2>
                <child2 label="child2c" />
            </child1>
            <child1 label="child1b" />
        </root>
    </mx:XML>

    <mx:ApplicationControlBar dock="true">
        <mx:CheckBox id="checkBox"
                label="showRoot:"
                labelPlacement="left"
                selected="true" />
    </mx:ApplicationControlBar>

    <mx:HDividedBox width="100%">
        <mx:Tree id="tree"
                dataProvider="{xmlDP}"
                labelField="@label"
                showRoot="{checkBox.selected}"
                width="100%"
                rowCount="7" />

        <mx:TextArea id="textArea"
                editable="false"
                text="{xmlDP.toXMLString()}"
                width="100%"
                height="100%" />
    </mx:HDividedBox>

</mx:Application>