| admin |
| Site Admin |
|
 |
| Joined: 25 Oct 2005 |
| Posts: 512 |
|
|
|
 |
Here is a handy dandy function for parsing nodes the dndTree. Yes, you can use it for the standard Macromedia Tree component.
Remember, you can also use the myTree.dataProvider.firstChild..toString() to get the xml as well.
| Code: |
// test function to parse through the nodes
parseTest_btn.onRelease = function() {
// parse nodes
var xmlObj = dndTree.dataProvider;
var level = 0;
function parseNodeValues(xmlNode) {
//create spacing
var spacer = "";
for (var j=0;j<level;j++) {
spacer += " ";
}
trace(spacer + " - " + xmlNode.attributes.label +"");
level++;
if (xmlNode.hasChildNodes()) {
for(var i =0;i<xmlNode.childNodes.length;i++) {
parseNodeValues(xmlNode.childNodes[i]);
}
}
level--;
}
parseNodeValues(xmlObj.firstChild)
} |
|
|