Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML to POJO and vice versa [duplicate]

Tags:

java

xml

pojo

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

like image 205
Java Developer Avatar asked Jun 27 '12 07:06

Java Developer


1 Answers

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)

like image 97
user278064 Avatar answered Sep 22 '22 20:09

user278064