在最后一个子节点之后添加一个节点

  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. newel=xmlDoc.createElement("edition");
  12.  
  13. x=xmlDoc.getElementsByTagName("book")[0];
  14. x.appendChild(newel);
  15.  
  16. document.write(x.getElementsByTagName("edition")[0].nodeName);
  17. </script>
  18. </body>
  19. </html>