By spm2ot
via sw-engineering-candies.com
Published: Jul 11 2012 / 09:51
To create XML form Java objects is something that can be very error prone, e.g. doing the correct encoding of the various data types can be tricky. This is the reason why you never should do this by your own in Java. One of my favorite library to convert objects form and to XML is XStream [1]. The XStream implementation is simple, strait forward and has a small footprint.
The following sample code is based on the current version 1.4.2 released in November 2011. It creates an instance of a class, serializes the object to XML and back again to a new object.
Comments
sproketboy replied ago:
XStream has a big gotcha. It's doesn't handle object versioning very well - but it is a lot faster than the standard Java XML encoder.
Voters For This Link (9)
Voters Against This Link (0)