As we know JAXB is used for XML binding with Java. Also Apache XmlBeans also used to XML binding with JAVA. Here I am going to say (Prove) which best to use?
JAXB
Advantages:
Sun's Implementation well known with JAX-WS & JAX-RPC Disadvantages:
To Marshall & UnMarshall we to write manual code. XmlBean
Advantages:
No need to write code to Marshall & UnMarshall Inbuilt support for Saxon xQuery & XPath All Bea products using (Weblogic Portal, Aqualogic Service Bus) Disadvantages:
Not known by many developers JAXB sample code to bind XML:
public class Main { public static void main(String[] args) { Object pud = unmarshall(some.pkg", TestDocument.class); marshall("poc.act.cms.poc", pud); } public static void marshall(String namesapce, Object object) { try { JAXBContext jc = JAXBContext.newInstance(namesapce); Marshaller m = jc.createMarshaller(); m.setProp