XML to POJO and vice versa

Java Developer picture Java Developer · Jun 27, 2012 · Viewed 22.9k times · Source

Possible Duplicate:
What is the best/simplest way to read in an XML file in Java application?

How do I convert XML to POJO and vice versa? does axis2 provide that capability? or does java already have built-in capability for this? or any other framework? thanks

Answer

user278064 picture user278064 · Jun 27, 2012

I really encourage you to use JAXB.

JAXB is an annotation framework that maps Java classes to XML and XML schema (and viceversa). It is extremely useful because instead of interacting with an abstract representation of an XML document, you can work with real Java objects that are closer to the domain you are modeling.

If you alos need to build a RESTful web-service, with automatic serialization/deserialization of Java Objects into XML, through JAXB, I also suggest you the reading of this book:

Oreilly RESTful Java with JAX-RS - (Chapter 6. JAX-RS Content Handlers)