We are using XML's to read and write data's instead of hitting into DB. Now the thing is whenever a data is posted to form we are able to create the new XML, but what we need is instead of creating new XML that data has to be appended to the existing file. Say i have Main.xml which has around 50 entries in it. If a user post the values, it has to be appended to that end of file, instead of read the file and copy all to new file and save it. How can it be done?
Please guys i need your help
Thanks in advance.
Never try to be a hard-worker. Be a smart-worker.
Well, first of all, appending something to an XML file (i.e. adding it at the end, after the end tag of the root element) makes that document be not well-formed. So that isn't what you want to do. You want to insert this "entry" (which I suppose is some kind of element) before the end tag of the root element.
And XML is just text. So the way to do that is to generate a new document. You do that by reading the old document and writing out a modified version of it. You can't modify it in place. Besides you mentioned JAXB. JAXB definitely doesn't work by modifying existing files.
Apparently you're saying that your "need" is to modify the existing document in place. Well, you can't do that. So you'll have to review this so-called need and find out what the basis is for it. Then you'll have to examine that basis, whatever it might be, and address it properly. Often requirements like this come from people who don't know what they are talking about, so be prepared for that possibility.