Guess it\'s a simple question for a javascript guru, but i\'m learning and got a problem I can\'t guess out.
I\'m interested in reading an XML file using javascript. He
In, this case, since the attribute
elements you are looking for are direct children of the object
element, a simple thing you can do is iterate through the child elements of the object
element by hand:
var obj = objList[0]
var childNodes = obj.childNodes
for(var i=0; i<childNodes.length; i++){
var child = childNodes[i];
if(child.nodeType == 1 && child.nodeName == 'attribute'){
do_something(child);
}
}
For information on these and other DOM methods, I recommend checking out the documentation over on MDN.
The problem you are running into is that technically "attributes" of subobject are also children of object. Remember that any element is a Node object, and on that Node you can get all childNodes. You can do that and process each "Element" node and determine if it is an "attribute" Node.
See http://www.w3schools.com/jsref/dom_obj_node.asp for more information on this.