1 Reply Latest reply on Jan 28, 2009 1:38 PM by manteratech

    XML Node

    manteratech
      Hi All,

      Im currently working on a tree that is using XML for its data. I received some help on an adding a node to its proper parent, however I can seem to come up with a way of tracking it so that I can add children to itself later.

      So for instance (sorry for the bad diagram)...

      myroot
      |--------node a id=1
      | -------node b id=2
      |------node c id 3

      I want to add a node to node "b" by search for its id and appending a child node. This is all coming from the database as I get records back based on the last parent. Im currently doing this(code) to add an item. But I dont know how to find the node. Is there a way to do it dynamically, other than telling it where like this "tmpBins:XMLList = MyBins..bin;"

      var newNode:XML = <bin/>;
      newNode.@title = 'Good';
      newNode.@isBranch = "true";
      newNode.@id = 25;
      var tmpBins:XMLList = MyBins..bin;
      var t:XMLList = tmpBins.(@id == binid);
      if(t.length() == 1)
      {
      t.appendChild(newNode);
      trace(t.parent().@id);
      }