Today my colleague, Chandana was trying to convert POJO to an XML file. In our company we are working with dom4j library, but unfortunately it does not provide the capabilities to convert a Java object on the fly to an XML.
Off course Chandana could always manually create new Document, root element, sub elements and attributes and that would work fine. But this still does not solves Chandana’s problem where she needed to generate XML on the fly.
After some time doing a research on the Internet she came across this very nice library call XStream. Its a very nice library which allows to serialize objects to XML and back again. It doesn’t require mapping nor modifications to the object itself. They also have a short tutorial which converts a POJO to an XML in few simple steps. Very nice and usefuL