flex如何删除一个XML Node

这几天在用flex做流程设计器时,遇到了需要删除XMl节点的问题,在网上搜了一下,有一种方案是将整个XML树重新构造一遍,在构造时将要删除的节点排除。这种方法对于流程设计器代价太高。无奈之下只好忍着头痛去Adobe的网站上看看E文去,终于黄天不负有心人,终于找到了,实例代码如下,下面的代码我测试过,可以正确运行
Title

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    width="440" height="400"   
    initialize="initializeHandler();"
>

    <mx:Script>
        <![CDATA[
       
            [Bindable] public var a:XMLList;
            [Bindable] public var b:XMLList;
            [Bindable] public var c:XMLList;
            [Bindable] public var d:XMLList;

            // Model: XML structure describing
            // some of the books in my collection.   
            [Bindable]
            private var myBooks:XML =
                <books>

                    <book ISBN="1590595181">
                        <title>Foundation ActionScript Animation: Making Things Move</title>
                        <author>Keith Peters</author>

                        <amazonUrl>http://tinyurl.com/npuxt</amazonUrl>
                        <pageCount>470</pageCount>
                    </book>

                    <book ISBN="1582346194">
                        <title>Send in the Idiots: Stories from the Other Side of Autism</title>

                        <author>Kamran Nazeer</author>
                        <amazonUrl>http://tinyurl.com/lo5ts</amazonUrl>
                        <pageCount>500</pageCount>

                    </book>
                </books>
           
            private function initializeHandler():void

            {
                // An XML list that contains both book nodes.               
                a = myBooks.book; 
               
                // Keith Peters        
                b = myBooks.book[0].author;
               
                // 470

                c = myBooks.book.(@ISBN=="1590595181").pageCount;

                // Delete the first book node.
                delete myBooks.book[0];
               
                // Send in the Idiots...
                d = myBooks.book[0].title;
            }
        ]]>
    </mx:Script>

   
    <!-- User interface -->
    <mx:Panel
        title="XML lookup results"
        paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10">

        <mx:Text text="{'a: ' + a}" width="300"/>
        <mx:Label text="{'b: ' + b}"/>       
        <mx:Label text="{'c: ' + c}"/>

        <mx:Label text="{'d: ' + d}"/>
    </mx:Panel>

</mx:Application>

posted on 2008-03-18 10:27  netlynx2000 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/netlynx2000/archive/2008/03/18/1111089.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值