案例:XSL案例     状态:不可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<body>
3
<script type="text/javascript">
4
function loadXMLDoc(dname)
5
{
6
if (window.XMLHttpRequest)
7
  {
8
  xhttp=new XMLHttpRequest();
9
  }
10
else
11
  {
12
  xhttp=new ActiveXObject("Microsoft.XMLHTTP");
13
  }
14
xhttp.open("GET",dname,false);
15
xhttp.send("");
16
return xhttp.responseXML;
17
}
18
19
xml=loadXMLDoc("/example/xmle/books.xml");
20
path="/bookstore/book[1]/title";
21
// code for IE
22
if (window.ActiveXObject)
23
{
24
xml.setProperty("SelectionLanguage","XPath");
25
var nodes=xml.selectNodes(path);
26
27
for (i=0;i<nodes.length;i++)
28
  {
29
  document.write(nodes[i].childNodes[0].nodeValue);
30
  document.write("<br />");
31
  }
32
}
33
// code for Mozilla, Firefox, Opera, etc.
34
else if (document.implementation && document.implementation.createDocument)
35
{
36
var nodes=xml.evaluate(path, xml, null, XPathResult.ANY_TYPE,null);
37
var result=nodes.iterateNext();
38
39
while (result)
40
  {
41
  document.write(result.childNodes[0].nodeValue);
42
  document.write("<br />");
43
  result=nodes.iterateNext();
44
  }
45
}
46
</script>
47
48
</body>