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>

你可能感兴趣的:(c,xml,Flex,Adobe,actionscript)