<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
var xmlDoc;
function fnOnLoad() {
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "books.xml", false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
}
function SelectTitleNode_price_gt_35() {
var buf = "";
path = "/bookstore/book[price>35]/title";
// code for IE
if (window.ActiveXObject) {
xmlDoc.setProperty("SelectionLanguage", "XPath");
var nodes = xmlDoc.selectNodes(path);
for (i = 0; i < nodes.length; i++) {
buf += "(IE) " + nodes[i].childNodes[0].nodeValue ;
buf += "<br/>";
}
} else {
// code for Mozilla, Firefox, Opera, etc.
if (document.implementation && document.implementation.createDocument) {
var nodes = xmlDoc.evaluate(path, xmlDoc, null, XPathResult.ANY_TYPE, null);
var result = nodes.iterateNext();
while (result) {
buf += "(Firefox) " + result.childNodes[0].nodeValue + "<br/>";
result = nodes.iterateNext();
}
}
}
document.getElementById("sec00").innerHTML = buf;
}
</script>
</head>
<body onload="fnOnLoad()">
<input type="button" value="Select TITLE nodes with price>35" onclick="SelectTitleNode_price_gt_35()" />
<div id="sec00"></div>
</body>
</html>
|