Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with xml file

Joseph Bashir
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using org.w3c.dom package I have written code to generate .xml file. i.e.

<?xml version="1.0" encoding="UTF-8"?>

The data for the xml file comes from a HTML Form. Everytime I submit the HTML Form, the data in the xml file is over-written by the new data.

What I want is that everytime I submit the HTML Form, the new data should be added and the old data should also exist. Can someone please tell me the solution. Here are few of the line of code;

Element main,root,item;

main = doc.createElement("Users");

root = doc.createElement("User");

item = doc.createElement("FirstName");

item = doc.createElement("LastName");

[ July 12, 2005: Message edited by: Joseph Bashir ]
Joe Ess
Posts: 9362
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You aren't telling us how you are creating your Document instance. I have a feeling you are creating an empty document and saving it over the existing one. Have a look at this example.
If that's not the problem than this line probably is:

I'm not sure, but I'll bet that if you create a new root Element with the same name as an existing one, the new Element replaces the old and wipes out your previous User node.
By the way, don't bother with the newline text nodes. XML isn't supposed to be a readable text document. Those newlines will just pollute your DOM and make navagating it more difficult.
Poop goes in a willow feeder. Wipe with this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!