tvks Posted December 1, 2006 Share Posted December 1, 2006 Hi,I had gone through the code in w3schools in the following addresshttp://www.w3schools.com/dom/met_element_removechild.aspI used it in my php program with a few minor modifications. My code is listed below: <html><head><script type="text/javascript" src="loadxmldoc.js"> </script></head><body><script type="text/javascript">//check if the last node is an element nodefunction get_lastchild(n){var x=n.lastChild;while (x.nodeType!=1){x=x.previousSibling;}return x;}xmlDoc=loadXMLDoc("books.xml");document.write("Number of book nodes: ");document.write(xmlDoc.getElementsByTagName('book').length);document.write("<br />");var lastNode=get_lastchild(xmlDoc.documentElement);var delNode=xmlDoc.documentElement.removeChild(lastNode);document.write("Number of book nodes after removeChild(): ");document.write(xmlDoc.getElementsByTagName('book').length);</script></body></html> When I executed this it is displaying me an output "Node removed: price" but there is no change in the file books.xml.Kindly help.Regards. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now