Results 1 to 6 of 6

Thread: Write to an XML file without overwriting

  1. #1
    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:
    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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.

  3. #3
    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.

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Write to an XML file without overwriting

    Hello,
    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.
    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.
    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.

  5. #5
    Join Date
    Dec 2009
    Posts
    263

    Re: Write to an XML file without overwriting

    Hello,
    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.
    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

  6. #6
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Write to an XML file without overwriting

    Hi,
    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.
    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.

Similar Threads

  1. Javascript write to file
    By Din_the1 in forum Software Development
    Replies: 4
    Last Post: 29-05-2010, 12:38 PM
  2. Open a txt file and write into it
    By Maya Angelou in forum Software Development
    Replies: 5
    Last Post: 25-03-2010, 01:59 PM
  3. Write to the middle of a file
    By Miles Runner in forum Software Development
    Replies: 5
    Last Post: 22-01-2010, 01:25 PM
  4. How to Write a Batch File ?
    By Ebenezer in forum Operating Systems
    Replies: 2
    Last Post: 30-07-2009, 02:39 PM
  5. Page displayed overwriting
    By Shashee in forum Technology & Internet
    Replies: 4
    Last Post: 28-03-2009, 03:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,726,977,008.64769 seconds with 17 queries