a simple version of this is built into java >=1.4 using the XMLEncoder
and XMLDecoder
classes.
a quick example
usage is quite simple, along the lines of
XMLEncoder xmlEncoder = new XMLEncoder( outputStream );
xmlEncoder.writeObject( myObject );
will give you something like
<?xml version="1.0" encoding="UTF-8"?>
<java>
<object class="your.class.Name">
<void property="fieldName">
<boolean>true</boolean>
</void>
etc. etc. etc.
</object>
</java>
to read back the object you simply do
XMLDecoder xmlDecoder = new XMLDecoder( inputStream );
MyClass thing = (MyClass) xmlDecoder.readObject();
here's a random tutorial i found on google:
http://www.avajava.com/tutorials/lessons/how-do-i-write-a-javabean-to-an-xml-file-using-xmlencoder.html
this method is not amazingly flexible, but it's built in, configuration free and very predictable. might be a good starting point.
some additional notes:
here's a document that outlines the xml format: http://java.sun.com/products/jfc/tsc/articles/persistence3/
and here is another link i just found, this explains how to
move from xmlencoder
to jaxb (built into jdk >= 1.6) for more flexibility:
http://en.newinstance.it/2010/08/05/javabeans-to-xml-with-no-libraries/