Unmarshalling is a process of converting the byte stream back to their original data or object. The conversion is achieved through "serialization".


JAXB stand for Java Architecture for XML Binding. Jaxb allows us to map Java classes to XML representations. JAXB can be used Java to marshal java object into xml or/and to unmarshal XML back into Java objects.

I used these 2 jar for this example. You can download latest version of jar and add it to your class path.

  1. jaxb-api-2.1.jar
  2. jaxb-impl-2.1.jar

Unmarshalling from a File

Unmarshalling from an InputStream

Unmarshalling from a URL

Unmarshalling from a StringBuffer using a javax.xml.transform.stream.StreamSource

Unmarshalling from a org.w3c.dom.Node

Unmarshalling from a javax.xml.transform.sax.SAXSource using a client specified validating SAX2.0 parser

Unmarshalling from a StAX XMLStreamReader

Unmarshalling from a StAX XMLEventReader

UnMarshalling example

Here is bookCatalog.xml, which we are going to unmarshall.


Here is BookCatalog.java. We are going to unmarshalled above xml into object of BookCatalog using Jaxb apis.



Source code of UnMarshalingMain.java is given below.



Share & Like

About ApnaTutorials.com

ApnaTutorials.com is for Java, J2ee, Html5 and android developers. All tutorials are well explained and are easy to understand. We have tested every tutorials on our developement environment before posting it in public domain.