51help TIY
码:
<html> <head> <script type="text/javascript" src="../example/xdom/loadxmldoc.js" tppabs="http://www.51help.tk/example/xdom/loadxmldoc.js"> </script> </head> <body> <script type="text/javascript"> // function get_lastchild(n) { var x=n.lastChild; while (x.nodeType!=1) { x=x.previousSibling; } return x; } xmlDoc=loadXMLDoc("/example/xdom/books.xml"); document.write("book :"); document.write(xmlDoc.getElementsByTagName('book').length); document.write("<br />"); var lastNode=get_lastchild(xmlDoc.documentElement); var delNode=xmlDoc.documentElement.removeChild(lastNode); document.write("removeChild() book :"); document.write(xmlDoc.getElementsByTagName('book').length); </script> </body> </html>
查看结果: