Enumerating Nodes

Table of contents
No headers

The following recipe walks the Service Pane nodes (from the root) and prints out the name of each node.

var Ci = Components.interfaces;
function printTree(node) {
    if (node.name != null)
        alert(node.name);
	
    if (node.isContainer) {
        var children = node.childNodes;
        while (children.hasMoreElements()) {
            var child = children.getNext().QueryInterface(Ci.sbIServicePaneNode);
            printTree(child);
        }
    }
}

var SPS = Components.classes['@songbirdnest.com/servicepane/service;1']  
        .getService(Components.interfaces.sbIServicePaneService);   
SPS.init();   
var root = SPS.root;
printTree(root);
Tag page
You must login to post a comment.