Skip to main content

Posts

Showing posts from December, 2013

Transform Object into XML using JAXB (Part 2)

In one of the posts  we had seen how to convert Java objects into XML. This was done using JAXB and XSD .  What if you don't like to write XSD by hand. Well, you can use any online or offline tools available, to generate the desired XSD from XML. Most of the times the generated XSD will be nearly accurate and you have to hand edit them to make it 100% perfect. Alright. What if you don't know XSD at all. Is there a simpler way? Yes there is. Here we are going to use a different approach to achieve exactly the same result that we have got in the  old  post. Open Netbeans and create a Java Application File->New Project->Java Application Enter "XMLBinding2" in the Project Name field Click Finish Create the following Java classes Replace the Java files with the following contents appropriately. package xmlbinding2; import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElementWrappe...