Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to store arraylist in xml file

 
Aditi Bhalerao
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My arraylist consists of beans of attrs: datasize, dataused, date
ArrayList<Beans> ie.

Xml pattern required:

<?xml version="1.0" encoding="UTF-8" ?>
<data>
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-09" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-08" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-10" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-11" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-15" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-16" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-17" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-18" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-19" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-22" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-23" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-24" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-25" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-02-26" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-02" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-03" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-04" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-05" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-09" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-10" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-11" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-12" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-17" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-18" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-19" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-22" />
<record DATASIZE="20.0" DATAUSED="1.8359375" DATE="2010-03-23" />
</data>

to be stored in xml file.This format is the required format as per API that i am using to display the graphical stuff.
this xml wud be read at the runtime from cache where this file is stored and wud display these values in graphical representation.

how can i achieve generation of xml file in required format???

this is my first ever project involving XMLs kindly help even if problem seems silly and simple.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i achieve generation of xml file in required format???


An XML document file is just text, nothing magical. Just write the file out with println statements, no need to get tangled up with JAXB or other apis.

Bill
 
Loganathan Murugesan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try out XML beans.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic