The following example shows serializing a POJO with simple map to an XML.
The POJO should have a no-arg default constructor and
@XmlRootElement annotation at class level.
MapData mapData = new MapData();
mapData.setData(countryMap);
/**
* Create JAXB Context from the classes to be serialized
*/
JAXBContext context = JAXBContext.newInstance(MapData.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.marshal(mapData, System.out);