Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 18-01-2010
Member
 
Join Date: Dec 2009
Posts: 263
Write to an XML file without overwriting

Hello,
I know do not how to add more data in an xml file without overwriting the content. I tried to add "true" by:
Code:
XMLEncoder en = new XMLEncoder(new FileOutputStream("file.xml",true));
But when I open the xml file, I have the following error:
Quote:
The XML page can not be displayed
Can not view XML input using XSL style sheet. Correct the error and then click the Refresh button, or try again later.
any help on this.
Reply With Quote
  #2  
Old 18-01-2010
Member
 
Join Date: May 2008
Posts: 2,008
Re: Write to an XML file without overwriting

Hello,
This allows writing to the end of the file, which generates an invalid XML file. I think you should avoid this. If you are going to use this then you have to regenerate the entire file. And this is I think a tedious job. You load your file into memory, you add the info you want to add, and you write the result in the file. Is this correct? I hope this is the procedure you are following to write your code.
Reply With Quote
  #3  
Old 18-01-2010
Member
 
Join Date: Dec 2009
Posts: 263
Re: Write to an XML file without overwriting

Hello,
I am sorry but your suggestion have not really helped me. I manage to insert data in my xml file, I just want to know how to insert without crushing the contents. If you could tell me first what is wrong in my code, it would be good for a start, because "load the file into memory, regenerate the file, sorry but it seems a little worry for me. Thank you.
Reply With Quote
  #4  
Old 18-01-2010
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: Write to an XML file without overwriting

Hello,
Quote:
I manage to insert data in my xml file, I just want to know how to insert without crushing the contents.
You write your own parser that opens an XML file in random access from the end back to the closing tag of document formats and writes the content to add, and then rewrites the tag. Good luck, nobody will do for you, and remember that you must remain 100% compliant XML. When you resign yourself to use the method that was given thee: Rebuild the entire file.
Quote:
If you could tell me first what is wrong in my code, it would be good for a start
There is nothing wrong with your code, but your idea. You can not add information to the end of an XML document.
Quote:
because "load the file into memory, regenerate the file, sorry but it seems a little worry for me.
I guess that's a joke and in reality you just do not see how it answers your question. This is normal, there is no realistic answer to your question.
Reply With Quote
  #5  
Old 18-01-2010
Member
 
Join Date: Dec 2009
Posts: 263
Re: Write to an XML file without overwriting

Hello,
Quote:
nobody will do for you
Now, I understand why you answer me, you think I want the facility, i.e someone gives me the code free and works? Well I will remember I first gave a code to explain what I did wrong and tell me how to insert a xml file without overwriting.
Quote:
There is nothing wrong with your code, but your idea. You can not add information to the end of an XML document.
I guess, I was asking for some ideas.
Thank you
Reply With Quote
  #6  
Old 18-01-2010
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: Write to an XML file without overwriting

Hi,
Quote:
You think I want the facility, ie someone gives me the code free and works?
In fact, it is a perfectly reasonable expectation when one deals with XML. After a little study of how this is supposed to be easy. At least, when trying to use it as prescribed. By corollary, it is highly recommended to invent itself its own solutions for processing XML. Simply because we rarely provides all the possible pitfalls, and that is the gateway to the inclusion of unnecessary bugs, difficult to repair, and identified at the worst possible time.
Quote:
Well I will remember I first gave a code to explain what we did wrong and tell me how to insert a xml file without overwriting.
To clarify, for example, an XML file has only one root element, then add another element to the root end of the file would malformed. Therefore, we can not add to the end of an XML file without crushing.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Write to an XML file without overwriting"
Thread Thread Starter Forum Replies Last Post
Javascript write to file Din_the1 Software Development 4 29-05-2010 12:38 PM
Open a txt file and write into it Maya Angelou Software Development 5 25-03-2010 01:59 PM
Write to the middle of a file Miles Runner Software Development 5 22-01-2010 01:25 PM
How to Write a Batch File ? Ebenezer Operating Systems 2 30-07-2009 02:39 PM
Page displayed overwriting Shashee Technology & Internet 4 28-03-2009 03:02 PM


All times are GMT +5.5. The time now is 03:49 PM.