Reputation: 591
I wish fetch data in a XML file, where Tag is a variable.. My XML looks like this:
<b0>123</b0>
<b1>111</b1>
Code:
var y = Math.round(d / 11);
var zzz = xmlDoc.getElementsByTagName("y")[0].childNodes[0].nodeValue;
Using the code above it will search in the XML "y" tag, but i want to search the result of "y" variable and since the XML has "b" before, the search in Tag should be something like this "b(y)". I´ve confirm that the results from "y" variable is always round numbers.
How can i acomplishe this?
Thanks in advance.
Upvotes: 0
Views: 1000
Reputation: 140220
var zzz = xmlDoc.getElementsByTagName("b" + y)[0].childNodes[0].nodeValue;
Upvotes: 1