案例:XML DOM案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript" src="/example/xdom/loadxmldoc.js"> 
4
</script>
5
</head>
6
<body>
7
8
<script type="text/javascript">
9
xmlDoc=loadXMLDoc("/example/xdom/books.xml");
10
11
newatt=xmlDoc.createAttribute("edition");
12
newatt.nodeValue="first";
13
14
x=xmlDoc.getElementsByTagName("title");
15
x[0].setAttributeNode(newatt);
16
17
document.write("Edition: ");
18
document.write(x[0].getAttribute("edition"));
19
20
</script>
21
</body>
22
</html>
23