忽略节点间的空文本

  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.documentElement.childNodes;
  11. for (i=0;i<x.length;i++)
  12. {
  13. if (x[i].nodeType==1)
  14. {
  15. document.write(x[i].nodeName);
  16. document.write("<br />");
  17. }
  18. }
  19. </script>
  20. </body>
  21. </html>