<?xml version="1.0"?> <bookstore> <book> <author>name1</author> <bookname>C# Programming</bookname> <price>$50</price> </book> <book> <author>name2</author> <bookname>C++ Programming</bookname> <price>$60</price> </book> <book> <author>name3</author> <bookname>Java Programming</bookname> <price>$60</price> </book> </bookstore>
<script type="text/javascript"> function getXMLValue() { if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET", "books.xml", false); xmlhttp.send(null); xmlDoc = xmlhttp.responseXML; var bNumber = xmlDoc.getElementsByTagName("book"); for (var i = 0; i < bNumber.length; i++) { for (var j = 0; j < 3; j++) { // Visit belong to all child nodes of 'book' . window.alert(xmlDoc.getElementsByTagName("book")[i].childNodes[j].childNodes[0].nodeValue); } } } </script>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)