Using XPATH in IE Using XMLDoc.SelectNodes(XPATH)
XML Doc
<?xml
version="1.0" encoding="ISO-8859-1"?>
< bookstore>
< book
category="COOKING">
< title
lang="en">Everyday Cooking</title>
< author>Sanjeev
Kapoors's</author>
< year>2010</year>
<
price>160.00</price>
< /book>
< book
category="CHILDREN">
< title
lang="en">Harry Potter</title>
< author>J K.
Rowling</author>
< year>2010</year>
<
price>350.00</price>
< /book> < book
category="WEB">
< title
lang="en">XQuery Kick Start</title>
< author>James
McGovern</author>
< author>Per
Bothner</author>
< author>Kurt
Cagle</author>
< author>James
Linn</author>
< author>Vaidyanathan
Nagarajan</author>
< year>2005</year>
<
price>249.50</price>
< /book> < book
category="WEB">
< title
lang="en">Learning XML</title>
< author>Erik T.
Ray</author>
< year>2006</year>
<
price>129.50</price>
< /book>
< /bookstore>
HTML
<!DOCTYPE html>
<html>
<body>
<script> function
loadXMLDoc(dname)
{
if (window. XMLHttpRequest)
{
xhttp=new XMLHttpRequest();
}
else
{
xhttp=new
ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",dname,false):
xhttp.send("");
return xhttp.responseXML;
}
xml=loadXMLDoc("books.xml");
path="/bookstore/book/title"
// code for IE
if (window.ActiveXObject)
{
var nodes=xml.selectNodes(path);
for
(i=0;i<nodes.length;i++)
{
document.write(nodes[i].childNodes[0].nodeValue);
document.write("<br>");
}
}
</script>
</body>
</html>