Reputation: 2785
I have the following XML:
-<collection>
-<beanRepresentation>
<beanRepName>7</beanRepName>
-<group>
<name>John</name>
<isFolder>true</isFolder>
-<condition>
<name>Normal</name>
</condition>
</group>
</beanRepresentation>
<collection>
I the above XML and I want to loop through < collection>
and get <name>
out.
This gets the < beanRepName>
:
var x=xmlDoc.getElementsByTagName("beanRepresentation");
for (i=0; i<x.length; i++) {
x[i].getElementsByTagName("beanRepName")[0].childNodes[0].nodeValue
}
But how do I get the <name>
field inside <group>
? i want to extract Normal
out.
Upvotes: 0
Views: 46
Reputation: 1477
var x=xmlDoc.getElementsByTagName('condition');
for(var i=0;i<x.length;i++)
document.write(x[i].childNodes[0].childNodes[0].nodeValue);
Upvotes: 1