首页 > 代码库 > flex 节点删除
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 <nodeToDelete> nodes"
click="btn1_clickHandler(event);" />
<mx:Button id="btn2"
label="delete <child label=‘two‘> node"
click="btn2_clickHandler(event);" />
</mx:ApplicationControlBar>
<mx:TextArea id="txtArea"
text="{someXML.toXMLString()}"
width="300" height="200" />