从文本节点获取文本

  1. <html>
  2. <head>
  3. <script type="text/javascript" src="/example/xdom/loadxmldoc.js"></script>
  4. </head>
  5. <body>
  6.  
  7. <script type="text/javascript">
  8. xmlDoc=loadXMLDoc("/example/xdom/books.xml");
  9.  
  10. x=xmlDoc.getElementsByTagName("title")[0].childNodes[0];
  11. txt=x.nodeValue;
  12. document.write(txt);
  13. </script>
  14. </body>
  15. </html>