根据对象删除属性

  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('book');
  12.  
  13. for (i=0;i<x.length;i++)
  14. {
  15. while (x[i].attributes.length>0)
  16. {
  17. attnode=x[i].attributes[0];
  18. old_att=x[i].removeAttributeNode(attnode);
  19.  
  20. document.write("被删除的:" + old_att.nodeName)
  21. document.write(": " + old_att.nodeValue)
  22. document.write("<br />")
  23. }
  24. }
  25. </script>
  26. </body>
  27. </html>