How to serialize an object to XML

I want to serialize an object to XML (actually, a list of objects over time).  the file will be append only (the list of objects can only grow).  

my object looks like this:  

public class MyObject{
     public String recordUID;
     public String userID;
     public String contentType;
     public String[] tags;
     public Date timeStamp;
     public String data;
     public String signature;

and I want to get an xml file that looks like this:

       <timeStam>23:59 2005</timeStamp>
       <data>CDATA here</data>
       <signature> CDATA here</signature>

are there any good ways to do this other than by hand?  and If I do do it by hand, which xml writer should I use?  
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use XMLEncoder

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I guess you can go for the solution CEHJ suggested in your previous question,
"XML Encoding / Deconding" if you don't care about the tag names.

However, if you want to define the tag names yourself, you can try any of

1. Castor -
2. Digester -
3. XMLBeans -
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Manikandan ThiagarajanSenior consultantCommented:
I had one question. What do you mean by file shall be append only.
once I create a xml file and save it, further invocation should only append data and not recreate a new file ?

If that is the case, then I think you need to read the xml file into java objects, add the objects that you want to add and then save the  entire object group back into the xml file.
// Serialize the document
      OutputFormat format = new OutputFormat(doc);
      XMLSerializer serializer = new XMLSerializer(System.out, format);
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.