案例:XML 实例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<body>
3
<script type="text/javascript">
4
if (window.XMLHttpRequest)
5
  {// code for IE7+, Firefox, Chrome, Opera, Safari
6
  xmlhttp=new XMLHttpRequest();
7
  }
8
else
9
  {// code for IE6, IE5
10
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
11
  }
12
xmlhttp.open("GET","/example/xmle/note.xml",false);
13
xmlhttp.send();
14
xmlDoc=xmlhttp.responseXML;
15
16
var x=xmlDoc.documentElement.childNodes;
17
18
for (var i=0;i<x.length;i++)
19
{ 
20
if (x[i].nodeType==1)
21
  { 
22
  //Process only element (nodeType 1) nodes
23
  document.write(x[i].nodeName + ": ");
24
  document.write(x[i].childNodes[0].nodeValue);
25
  document.write("<br />");
26
  } 
27
}
28
</script>
29
</body>
30
</html>
31