向文本节点添加数据

  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. var x=xmlDoc.getElementsByTagName("title")[0].childNodes[0];
  12. document.write(x.nodeValue);
  13. x.insertData(0,"Hello ");
  14. document.write("<br />");
  15. document.write(x.nodeValue);
  16.  
  17. </script>
  18. </body>
  19. </html>