案例: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.getElementsByTagName('book');
11
12
for (i=0;i<x.length;i++)
13
{
14
newComment=xmlDoc.createComment("Revised March 2008");
15
x[i].appendChild(newComment);
16
}
17
18
for (i=0;i<x.length;i++)
19
{
20
document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
21
document.write(" - ");
22
document.write(x[i].lastChild.nodeValue);
23
document.write("<br />");
24
}
25
</script>
26
</body>
27
</html>
28