File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes writing updated data  in to DOM memory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "writing updated data  in to DOM memory" Watch "writing updated data  in to DOM memory" New topic
Author

writing updated data in to DOM memory

s ithu
Greenhorn

Joined: Apr 10, 2012
Posts: 11
Hi guys,
I am trying to delete a specified node in xml file using dom parser.It work perfectly alright in IDE output terminal but xml file is not updating.How to solve this problem?

Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19691
    
  10

When you use the DOM parser, it reads from the XML file and creates data structures (the DOM) in your computer's memory. When you delete the node from the DOM, that doesn't have any effect on the file you parsed from, it only affects the data in memory.

If you want the original file to be changed as well, then after you make your changes to the DOM you have to write the DOM out to that file. The Ranch has an FAQ page called Document To File (follow that link) which explains just how to do that.
s ithu
Greenhorn

Joined: Apr 10, 2012
Posts: 11
Thank you very much for your help.
The correct code is
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: writing updated data in to DOM memory
 
It's not a secret anymore!