案例: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
//check if the last childnode is an element node
10
function get_lastchild(n)
11
{
12
x=n.lastChild;
13
while (x.nodeType!=1)
14
  {
15
  x=x.previousSibling;
16
  }
17
return x;
18
}
19
20
xmlDoc=loadXMLDoc("/example/xdom/books.xml");
21
x=xmlDoc.getElementsByTagName("book")[0];
22
23
newNode=xmlDoc.createElement("publisher");
24
newText=xmlDoc.createTextNode("Clarkson Potter");

 运行结果 
 北美留学生论坛