Link Details

Link 818437 thumbnail
User 412017 avatar

By spm2ot
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.
  • 9
  • 0
  • 1737
  • 787
User 187417 avatar

sproketboy replied ago:

0 votes Vote down Vote up Reply

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.

Add your comment

Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Apache Hadoop
Written by: Piotr Krewski
Featured Refcardz: Top Refcardz:
  1. Play
  2. Akka
  3. Design Patterns
  4. OO JS
  5. Cont. Delivery
  1. Play
  2. Java Performance
  3. Akka
  4. REST
  5. Java