Building JavaScript objects representing a tree
<pre><code>function createObjects(element, depth){
    element.label = element.getElementsByTagName("label")[0].firstChild.nodeValue;
    element.url = element.getElementsByTagName("url")[0].firstChild.nodeValue;
    element.depth = depth;
    if(treeWidths[depth] == undefined){
            treeWidths[depth] = 1;
    } else {
            treeWidths[depth]++;
    }

    element.children = new Array();
    allNodes.push(element);

    var children = element.getElementsByTagName("children")[0].childNodes;
    for(var i=0; i&lt;children.length; i++){
            if(children[i].nodeType != 3 &amp;&amp; children[i].tagName == "node"){
                    element.children.push(createObjects(children[i], depth+1));
            }
    }

    element.expanded = false;
    element.visible = false;
    element.moved = false;
    element.x = 0;
    element.y = 0;

    if (getNodeWidth() &lt; element.label.length * 10)
            element.width = element.label.length * 10;
    else
            element.width = getNodeWidth();
    element.height = getNodeHeight();
    return element; }
</code></pre>

<p>Having problems with Firefox, it says that 'element.children.push' is not a function but works (only) in Google Chrome...</p>

<p>Any clue?</p>
