<html> <body> <script type="text/javascript"> // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load("books.xml"); var x=xmlDoc.getElementsByTagName("book")[0]; document.write("Child nodes before removal: "); document.write(x.childNodes.length); x.removeChild(x.childNodes[0]); document.write("<br />Child nodes after removal: "); document.write(x.childNodes.length); </script> </body> </html>
Your Result:
Edit the code above and click to see the result.
W3Schools.com
- Try it yourself