案例:XML DOM案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript" src="/example/xdom/loadxmldoc.js">
4
</script>
5
<script type="text/javascript">
6
//check if the first node is an element node
7
function get_firstChild(n)
8
{
9
y=n.firstChild;
10
while (y.nodeType!=1)
11
  {
12
  y=y.nextSibling;
13
  }
14
return y;
15
}
16
</script>
17
</head>
18
19
<body>
20
<script type="text/javascript">
21
xmlDoc=loadXMLDoc("/example/xdom/books.xml");
22
23
x=get_firstChild(xmlDoc.getElementsByTagName("book")[0]);
24
document.write(x.nodeName);
25
</script>
26
</body>
27
</html>
28