How do I get the attribute value of an XML node with Javascript / jQuery?
I\'m trying to get the value of the duration attribute on the node, then get the fixedValu
The first problem I ran into is that currLoadXml is not a string. It needs to be wrapped inside single quotes.
Try using the below method
var currentLoanRates = function() {
var currLoanXml = ' ',
xmlDoc = $.parseXML( currLoanXml ),
$xml = $( xmlDoc ),
$intRate = $xml.find("interestRate");
$intRate.each(function(index, element) {
if(element.attributes["duration"]) {
console.log("Duration :" + element.attributes["duration"].value);
}
if(element.attributes["fixedValue"]) {
console.log("Fixed value:" + element.attributes["fixedValue"].value);
}
});
};