改变元素的文本节点

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