案例: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 next sibling node is an element node
9
function get_nextsibling(n)
10
{
11
var x=n.nextSibling;
12
while (x.nodeType!=1)
13
  {
14
  x=x.nextSibling;
15
  }
16
return x;
17
}
18
19
xmlDoc=loadXMLDoc("/example/xdom/books.xml");
20
21
var x=xmlDoc.getElementsByTagName("title")[0];
22
document.write(x.nodeName);
23
document.write(" = ");
24
document.write(x.childNodes[0].nodeValue);
25
26
var y=get_nextsibling(x);
27
28
document.write("<br />Next sibling: ");
29
document.write(y.nodeName);
30
document.write(" = ");
31
document.write(y.childNodes[0].nodeValue);
32
</script>
33
</body>
34
</html>
35