Jquery and XML - How to add the value of nodes
- by Matias
Hi Experts,
This may be a simple question though can´t figure out how to do it.
I am parsing an XML with Jquery Ajax. It contains dates and rates
The XML looks something like
<rate>
<date>Today</date>
<price>66</price>
</rate>
<rate>
<date>Tomorrow</date>
<price>99</price>
</rate>
I simply want to figure out how to calculate the total price of both days Today and Tomorrow. Thought that by using Javascript Number it will simply return the total value of the nodes..
$(xml).find("rate").each(function()
{
$(this).find("price").each(function()
{
$("#TOTALPRICE").append(Number($(this).text()));
}
}
//output is: 6699
However, it´s just concatenating the values both not adding them.
//output is: 6699
I greatly appreciate your help !!
Thanks