Monday, February 16, 2015

JAXB sample

JAXB, stands for Java Architecture for XML Binding, using JAXB annotation to convert Java object to / from XML file.

No need of external jar library files. JAXB is bundled in from JDK 1.6.

Basic features :
Marshalling – Convert a Java object into a XML file.
Unmarshalling – Convert XML content into a Java Object.

Model class
create a model class by using jaxb annotation to convert model class into xml file.

Generate/Convert Model object to xml
JAXB marshalling convert customer object into a XML file i.e. jaxbMarshaller.marshal().

Convert XML to Object
JAXB unmarshalling convert a XML file content into a customer object i.e. jaxbMarshaller.unmarshal()

Full source code:

0 comments:

Post a Comment