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

  <book category="cooking">
    <title language="English">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
  <book category="Politics">
    <title language="Malay">Malaysia Boleh</title>
    <author>Intan Baizura</author>

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

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