1
2
3
4
5
6
7
8
9
10
11
12
// Find a child element by name and index (nth element of that name)
XMLNode.prototype.findChild = function(name, index){
var count = 0;
var currNode = this.firstChild;
do{
if (currNode.nodeName == name){
count++;
if (count == index) return currNode;
}
}while (currNode = currNode.nextSibling);
return false;
}