flex 节点删除

<mx:Script>
        <![CDATA[
            protected function btn1_clickHandler(evt:MouseEvent):void {
                delete someXML.nodeToDelete;
                txtArea.text = someXML.toXMLString();
            }
 
            protected function btn2_clickHandler(evt:MouseEvent):void {
                delete someXML.child.(@label == 'two')[0];
                txtArea.text = someXML.toXMLString();
            }
        ]]>
    </mx:Script>
 
    <mx:XML id="someXML">
        <root>
            <child label="one" />
            <child label="two" />
            <child label="three" />
            <nodeToDelete label="four" />
            <child label="five" />
            <nodeToDelete label="six">
                <child label="seven" />
                <child label="eight" />
            </nodeToDelete>
            <child label="nine" />
        </root>
    </mx:XML>
 
    <mx:ApplicationControlBar dock="true">
        <mx:Button id="btn1"
                label="delete &lt;nodeToDelete&gt; nodes"
                click="btn1_clickHandler(event);" />
        <mx:Button id="btn2"
                label="delete &lt;child label='two'&gt; node"
                click="btn2_clickHandler(event);" />
    </mx:ApplicationControlBar>
 
    <mx:TextArea id="txtArea"
            text="{someXML.toXMLString()}"
            width="300" height="200" />

posted @ 2014-07-20 00:50  星火卓越  阅读(220)  评论(0编辑  收藏  举报