4

In a Flex application, I'm have an xml object that I'm binding to a tree control. I'm able to add a child node to the xml but when I try to add a child to the child node it doesn't appear on the tree control

tree =  <node label="Root">
                        <node label="Category 1"/>
                        <node label="Category2"/>
                        <node label="Category3"/>
                        <node label="Category 4">
                            <node label="SubCategory4.1"/>
                            <node label="SubCategory4.2"/>
                        </node>
                    </node>;                    
            var someNode:XMLNode = new XMLNode(9, 'Category5');         
            var aSubNode:XMLNode = new XMLNode(9, 'SubCategory5.1');
            someNode.appendChild(aSubNode);                                 
            tree.appendChild(someNode);

So Category5 appears on the tree control but SubCategory5.1 does not. What am I missing?

1 Answer 1

6

If you are using flex, use AS3. XMLNode is AS2. In short, try this:

tree = <node label="Root">
           <node label="Category 1"/>
           <node label="Category2"/>
           <node label="Category3"/>
           <node label="Category 4">
               <node label="SubCategory4.1"/>
               <node label="SubCategory4.2"/>
           </node>
       </node>;
var someNode:XML = <node label="Category5"/>;
var aSubNode:XML = <node label="SubCategory5.1"/>;
someNode.appendChild(aSubNode);
tree.appendChild(someNode);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.