I'm new in XML. I know this is an easy question but I need to find and display total price of the books. below is the XML

<bookstore>
  <book category="cooking">
    <title language="English">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2012</year>
    <price>35.00</price>
  </book>
  <book category="Politics">
    <title language="Malay">Malaysia Boleh</title>
    <author>Intan Baizura</author>
    <year>2014</year>
    <price>25.00</price>
  </book>
</bookstore>

book = xmlDoc.getElementsByTagName(“book”);
x= book[i].childNode[3].childNode[0].nodeValue;
var total = 0;
for (i=0;i<x.length;i++){
total+=parseFloat(x);
}
document.write(total);

I have tried as shown above. Is this the right way to this? I don't know if it is correct. Is there any alternatives to do this? Thank you.

0 Answers