Java tutorial
import java.util.ArrayList; import java.util.List; import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlValue; public class Main { public static void main(String[] args) throws Exception { Root root = new Root(); Book cDev = new Book(); cDev.setName("C Development"); root.getEmployeeDesiredSkills().add(cDev); Book perlDev = new Book(); perlDev.setName("Perl Development"); root.getEmployeeDesiredSkills().add(perlDev); JAXBContext jc = JAXBContext.newInstance(Root.class); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(root, System.out); } @XmlRootElement public static class Root { private List<Book> empBooks = new ArrayList<Book>(); public List<Book> getEmployeeDesiredSkills() { return empBooks; } public void setEmployeeDesiredSkills(List<Book> employeeDesiredSkills) { this.empBooks = employeeDesiredSkills; } } public static class Book { private String name; @XmlValue public String getName() { return name; } public void setName(String name) { this.name = name; } } }