[RESOLVED] Parsing an Actual XML Document via Ajax

admin

Administrator
Staff member
I have a recursive function that I'm starting off like this:

list = xmlhttp.responseXML.documentElement;
if((items = list.childNodes).length > 0) {
list = document.createElement("UL");
list.id = type+"List";
BuildCategoryItems(list, items, type);
obj.appendChild(list);
}

Then, the function is as follows:

function BuildCategoryItems(list, items, type) {
var sub, subitm, obj, x, len = items.length;
for(x=0; x<len; ++x) {
obj = list.appendChild(document.createElement("LI"));
obj.CCid = items[x].getAttribute('Id');
obj.CCtype = type;
obj.onclick = HilightListItem;
obj.appendChild(document.createTextNode(items[x].getAttribute('Title')));
if((subitm = items[x].childNodes).length > 0) {
obj.className = "plus";
sub = obj.appendChild(document.createElement("UL"));
sub.style.display = "none";
BuildCategoryItems(sub, subitm, type);
} else {
obj.className = "bullet";
}
}
}

The purpose, of which, is to transform an XML document into an HTML Unordered List with up to nine levels deep. This is working in IE, but is failing in FF at the method shown in red. Sorry, but I'm completely new to parsing XML documents and I don't know what I should be using to retrieve node attributes. Help?

TIA
 
Top