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