Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Editing data after retrieving from XML file and saving again

 
Sana Ali
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am trying to load data from an xml file in a form edit that info and update the xml file.

Currently I am able to view some information in the form.

But when I try and save (plus go to another page to perform save and display function) i have the following code:

/* Start of serialization code */

File myFile = new File(fileName);

//write the XML out into a file on the filesystem of the web server
FileWriter writer = new FileWriter(myFile, false);

//Create a new OutputFormat
OutputFormat format = new OutputFormat();
format.setIndenting(true);

//Create a new XMLSerializer that will be used to write out the XML
//Pass to it the writer object that defines where the output will
//be written to, and the format object that defines the format in
//which the XML will be generated
XMLSerializer serializer = new XMLSerializer(writer, format);

// Call the serialize() method, and pass to it out XML document
// stored in memory in a DOM tree
serializer.serialize(document);

/* End of serialization code */

The problem is instead of changing the values of the existing data, my code adds the new information to a new node to the xml tree.=\

Please Help.
Sana
[ October 21, 2004: Message edited by: Sana Ali ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64967
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the XML forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic