Parsing XML files with SIMPLE

SIMPLE XML serialization .

It’s an independent open source project , third party download for free at : http://simple.sourceforge.net

the simple API allows us to both read and write XML content using a annotated model, similar to JAXB , However much lightweight .

annotating a pojo properties : Placing annotation before class declarations or fields

@ Root , @ Attribute , @Element

We can also define a collection class just like in JAXB : by creating a separate class with a collection field , and an annotated class as a root element as children list.

Some of it’s Cons are : Large documents can cause Java to run out of heap space , the annotation model is unique to Simple, not portable to others APIs

Serializing and deserializing object using simple :

To serialize an instance of the above object a Persister is required. The persister object is then given an instance of the annotated object and an output result, which is a file in this example

Deserialization process is just as simple. The persister is given the class representing the serialized object and the source of the XML document. To deserialize the object the read method is used, which produces an instance of the annotated object.

Citation : David Gassner , http://simple.sourceforge.net/ , https://www.rhyous.com/2012/05/24/xml-serialization-in-java-using-simple/

Leave a comment