For serializing
a Java object into XML, you can use an open source Java library called
XStream. For using this library you have to download and install it
and then use the following import statement in your Java code.
_______________________________________________
import
com.thoughtworks.xstream.XStream;
Once you
have included this class in your code, you can create an XStream object
and then use that object to serialize any class you want. To create
an xstream object you will be writing code like,
XStream
xstrm = new XStream();
Suppose
you have a class called 'car' with the member variables like 'model'
and 'make' which is written as given below.
class car
{
string model;
string make;
}
You can
serialize this class using the following code,
String
xml = xstrm.toXML(car);
Now use
a print statement to print the values of the string xml. You can also
deserialize the XML to Java objects. Sample code for these conversions
is available in the internet.