<html> <head> <script type="text/javascript" src="/upload/file/xml/loadxmldoc.js"> </script> </head> <body> <script type="text/javascript"> xmlDoc=loadXMLDoc("/upload/file/xml/books_ns.xml"); var x=xmlDoc.getElementsByTagName("book")[0]; var ns="http://www.w3schools.com/edition/"; x.setAttributeNS(ns,"edition","first"); document.write(x.getAttributeNS(ns,"edition")); </script> </body> </html>
编辑上面的文字,按下“查看结果”,效果会显示在右边 Create by 软晨网(RuanChen.com)