• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 54. Tree > Populating the Tree with an Internal XML Document

Populating the Tree with an Internal XML Document

Just because we can (and this is the most likely way you'll populate this component), let's use an internal XML document to populate the Tree.

var classes_xml:XML = new XML();

// create XML elements
classes_node = classes_xml.createElement("node");
dogs_node = classes_node.cloneNode(true);
full_node = classes_node.cloneNode(true);
tango_node = classes_node.cloneNode(true);
three_node = classes_node.cloneNode(true);
burn_node = classes_node.cloneNode(true);
twenty_node = classes_node.cloneNode(true);

// add attributes
classes_node.attributes.label = "Classes";
dogs_node.attributes.label = "XML For Dogs";
full_node.attributes.label = "Full";
tango_node.attributes.label = "Tango Fundamentals";
three_node.attributes.label = "3 spots left";
burn_node.attributes.label = "Black Rock City Civics";
twenty_node.attributes.label = "20,000 spots left";

// place elements
classes_xml.appendChild(classes_node);
classes_node.appendChild(dogs_node);
classes_node.appendChild(tango_node);
classes_node.appendChild(burn_node);

dogs_node.appendChild(full_node);
tango_node.appendChild(three_node);
burn_node.appendChild(twenty_node);

// fill the tree
classes_tree.dataProvider = classes_xml;


					  


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint