Hi, Im trying to delete a node in XML file using Javascript. The used browser is Firefox. Im reaching the node which I want to delete successfuly, then Im trying delNode.ParentNode.RemoveChild(delNode) but when i went back to the xml file on my harddisk, the node was still there. I need to delete the whole node (not only children). If someone could guide me to what to do, I'll be so greatful ;) Thanks
That should remove delNode. Are you getting an error? What is the result of delNode.parentNode.removeChild(delNode) ? I do the same thing all the time and it works for me.
I'm sorry I missed the part about writing it back to the file. Use nsiFile to do that and a chrome:// url. In order to take advantage of these things you'll probably have to create a directory with a directory called 'chrome' which will have your script, a chrome.manifest file.
Hi, Thanks for the help. I couldn't find a way to change the content of the file in javascript so I used PHP. I was trying simply to delete the first node in my xml activity1.xml ... here is the code
$xdoc = new DomDocument; $xdoc->Load('images\activity\activity1.xml'); $xdoc->documentElement->removeChild($xdoc->documentElement->childNodes->item(1)); $xdoc->save('images\activity\activity1.xml');
it simply delete the first node whatever children it has ;)