To serialize
Java objects to XML easily you can use the open source Java library
XStream. This Java library is available for download at
_______________________________________________
_______________________________________________
http://xstream.codehaus.org/download.html
Once you
install this library you have to include the following import statement
in your Java code to work with the classes and the methods available
in that library.
import
com.thoughtworks.xstream.XStream;
Consider
that you have a class as given below,
class user
{
string name;
string address;
int telno;
}
By creating
an XStream object first, and then using the toXML() method of that object
you can serialize the 'user' class as given below.
XStream
xstrm = new XStream();
String xml = xstrm.toXML(user);
You can
use the print statements to print the output of the string xml. Similarly
you can also deserialize the XML documents to Java objects. Lots of
sample codes to do the conversion from Java objects to the XML and then
to deserialize them to Java objects are available in many websites in
the internet.