案例:XML DOM案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript" src="/example/xdom/loadxmldoc.js"></script>
4
</head>
5
<body>
6
7
<script type="text/javascript">
8
xmlDoc=loadXMLDoc("/example/xdom/books.xml");
9
10
x=xmlDoc.documentElement.childNodes;
11
for (i=0;i<x.length;i++)
12
{ 
13
if (x[i].nodeType==1)
14
  { 
15
  document.write(x[i].nodeName);
16
  document.write("<br />");
17
  y=x[i].childNodes;
18
  for (j=0;j<y.length;j++)
19
    { 
20
    if (y[j].nodeType==1)
21
      { 
22
      document.write(y[j].nodeName);
23
      document.write(": ");
24
      document.write(y[j].childNodes[0].nodeValue);
25
      document.write("<br />");
26
      } 
27
    }
28
  document.write("<br />");
29
  } 
30
}
31
</script>
32
</body>
33
</html>
34