Link to home
Start Free TrialLog in
Avatar of jjacksn
jjacksn

asked on

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:

<MyObjects>
<MyObject>
      <recordUID>1234</recordUID>
      <userID>me</userID>
      <contentType>something</conentType>
      <tags>
                <tag>tag1</tag>
                <tag>tag2</tag2>
       </tags>
       <timeStam>23:59 2005</timeStamp>
       <data>CDATA here</data>
       <signature> CDATA here</signature>
</MyObject>

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?  
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial