// (ref) http://extjs.com/forum/showthread.php?t=3987

function createTree(id,treeNode) {
  var treePanel = new Ext.tree.TreePanel(id, {animate:false, containerScroll:false, enableDD:false });
  treePanel.setRootNode(treeNode);
  treePanel.render();
}


function treeNodeFromXml(xml) {
	xml = xml.documentElement || xml;
	//	Text is nodeValue to text node, otherwise it's the tag name
	var t = ((xml.nodeType == 3) ? xml.nodeValue : xml.tagName);

	//	No text, no node.
	if (t.replace(/\s/g,'').length == 0) {
		return null;
	}
	var result = new Ext.tree.TreeNode({
        text : t
  });

  //	For Elements, process attributes and children
	if (xml.nodeType == 1) {
		Ext.each(xml.attributes, function(a) {
			var c = new Ext.tree.TreeNode({
				text: a.nodeName
			});
			c.appendChild(new Ext.tree.TreeNode({
				text: a.nodeValue
			}));
			result.appendChild(c);
		});
		Ext.each(xml.childNodes, function(el) {
	// Only process Elements and TextNodes
			if ((el.nodeType == 1) || (el.nodeType == 3)) {
				var c = treeNodeFromXml(el);
				if (c) {
					result.appendChild(c);
				}
			}
		});
	}
	return result;
}
