aspose file tools*
The moose likes XML and Related Technologies and the fly likes How to avoid overwrite in the XML while marshal mentioned inside of for loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to avoid overwrite in the XML while marshal mentioned inside of for loop" Watch "How to avoid overwrite in the XML while marshal mentioned inside of for loop" New topic
Author

How to avoid overwrite in the XML while marshal mentioned inside of for loop

Srinivasan Chinnaraj
Greenhorn

Joined: Mar 18, 2013
Posts: 6

I am trying to marshal java object into XML. i want to marshal java object into XML while it inside the for loop.

for(i=0;i<=2;i++){

........................
...........................
...........................

jaxbMarshaller.marshal(details, xmlFile);

}

for the above code it's overwriting in the XML file after completion of each loop . but i want to write in new line after completion of each loop. Please let me know , how to do?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

Please do take out time to CarefullyChooseOneForum. I have moved your topic to a more appropriate forum. The original forum you had posted is for questions related to the Ranch


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
You code does exactly what it says, repeatedly writes to the same file.

Just marshal the whole collection, then you will get the correct XML document root and the members.

Bill

 
Don't get me started about those stupid light bulbs.
 
subject: How to avoid overwrite in the XML while marshal mentioned inside of for loop