Open Source developer. http://simple.sourceforge.net http://www.simpleframework.org Jim has posted 1 posts at DZone. View Full User Profile

Simple 2.4 - Java XML Serialization

12.05.2010
| 2873 views |
  • submit to reddit
Location: 
http://simple.sourceforge.net/

Simple is an XML configuration and serialization framework for Java. It provides an annotated approach to XML serialization that offers full object graph serialization and deserialization for Android, Google App Engine, and Java 1.5+.

Simple XML Home

This contains various changes to constructor injection for better matching and also introduces a very useful new annotation called @Path. This path takes a single value, which is an XPath expression defining the location of either an attribute or element. For example

 

@Path("path/to/element")
private String value;
 

 

Which produces a wrapper such as

 

<path>
   <to>
      <element>
         ...

 

This is fully backward compatible and can be used with any of the element annotations and also the attribute annotation. This allows an otherwise flat object definition to be mapped in to a more complex XML structure. Such mappings reduce the number of object definitions required and also improves the frameworks XML binding capabilities. For some examples, see the tutorial.

Simple XML Tutorial

0
Average: 5 (1 vote)
Published at DZone with permission of its author, Jim Watson.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)