//var xml holds the Document Object var priceElements = xml.getElementsByTagName("price"); //returns a NodeList of all elements with the tag price var i; for (i=0;i < priceElements.length;i++) { // looping over all those price elements var USAprice = parseFloat(priceElements.item(i).firstChild.nodeValue); //the firstChild property returns the Text node //of this Text node we take the nodeValue, being the text itself //we convert this text to a number (floating) priceElements.item(i).setAttribute("unit","Canadian dollar"); //we set the attribute "unit" to value "Canadian dollar" var convertedprice = USAprice * 1.4; //we convert the price to Canadian dollar var newprice = xml.createTextNode(convertedprice); //we create a new Text node containing the new price priceElements.item(i).replaceChild(newprice, [ccc] priceElements.item(i).firstChild); //we replace the old Text node with the new one }