Link Details

Link 818437 thumbnail
User 412017 avatar

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.
  • 9
  • 0
  • 1680
  • 787

Comments

Add your comment
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.

Voters For This Link (9)



Voters Against This Link (0)



    Java Performance Optimization
    Written by: Pierre-Hugues Charbonneau
    Featured Refcardz: Top Refcardz:
    1. Design Patterns
    2. OO JS
    3. Cont. Delivery
    4. Java EE7
    5. HTML5 Mobile
    1. Node.js
    2. Debugging JavaScript
    3. OO JS
    4. JSON
    5. Ajax