Understanding XML serialization of Java objects

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.

Google releases serialization scheme (The Register)
Pedantic programmers hold love-in Fail and You Protocol buffer : it's the object serialization scheme the pretentious little shit on your development team has been talking at you about during lunch hours for the past couple of days. You've been feigning interest with a steady stream of "oh-yeahs" and "that-sounds-cools", so you don't really know what it is.…



FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

_______________________________________

Recommended XML Books

cover
cover
cover
cover
cover
cover


 

 

FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.

 

 

Add to My Yahoo!


New XML Books Titles - Best Seller's @ Amazon.com

Visit XML Training Material Guide Homepage

Technology helps engage students - how do classroom instruction and social dynamics change when the classroom is completely dependant on modern technology?

Dallas Web Design- local Dallas web design firm offers site design and backend system development