Reputation: 11
Im reading an XML file with ajax. Everything is working, I have just no idea how to get the string out of the xml file. The xml file looks like this:
<file>
<data>
<name>Brittus</name>
</data>
<bank>
<money id="1">10</money>
<money id="2">25</money>
<money id="3">40</money>
<money id="4">60</money>
</bank>
</file>
Now I would like to get the value of the tag money with the attribute 4. How can i get it with javascript?
file = responseObject.responseXML;
alert(file.getElementsbyTagName("money")[2].//an now?
And how to get the value of the money tag with id 2?
Thank you
Upvotes: 1
Views: 1222
Reputation: 1287
file.getElementsByTagName('money')[2].firstChild.nodeValue
The first Child of <money>
is a textnode.
Upvotes: 1