2 Replies Latest reply on Jan 5, 2007 7:30 PM by kimbflex

    changing a tree's xml data

    kimbflex Level 1

      I've been updating my trees xml data by doing this:

      var node:XML = stTree.selectedItem as XML;
      var p:* =node.parent();
      var c:* =node.childIndex();
      var s:* = stTree.selectedIndex;
      var insert:XML = new XML('<i item="some stuff">');
      stTree.dataDescriptor.addChildAt(p, insert, c);
      stTree.dataDescriptor.removeChildAt(p,null,c + 1);

      But it's getting a litle slow to process now my xml is now over 2,000 lines.

      Is there more efficient way than adding/removing a child? I can't see a simple way to edit the attributes of a the xml child element this way.
        • 1. Re: changing a tree's xml data
          ntsiii Level 3
          You can set the values of the attributes using syntax like this:
          node.@item = "some stuff";

          And you seem to have found another way to delete a node. I've used delete, and collection.removeItemAt(), but never dataDescriptor.removeChildAt()

          Tracy
          • 2. changing a tree's xml data
            kimbflex Level 1
            i thought i tried the obvious @ attrib and that didn't work, will tryi it again.

            yeah Tracy, but if you delete, edit and/or replace a tree node there seems no other way to maintain the focus on that tree node unless you do it this way. try it yourself mate.

            (I expect the chap to help me out here nudge nudge!)

            Yours.
            The increasingly irritated Flex programmer.

            EDIT {
            I just thought that since I have no access to the *computer* through Flex I or noone else could ever be called a Flex 'programmer' . You are script code editor for a JIT bytecode engine. How does that sound?
            }