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
loading...
Related posts:
- Convert XML into POJO using HierarchicalStreamReader
In this example I would like to show how unmarshall XML into a POJO using HierarchicalStreamReader. I will introduce how to use XStream... - Bitwise Operation In Hibernate 3
Hi all… i encountered a small problem in doing bitwise operations with hibernate. Until now, HIbernate 2 HQL parser has supported bitwise operations.... - Marshalling VS Serialization
The two terms are very very similar, and often treated the same. Quite few responds on various forums contradict each other, which made... - Hibernate Event Interceptor
Its quite common when you create an application, there is a need to create an audit trail on the application level where all... - How to Set SecurityManager and Java Security Policy Programmatically
In this example I want to show how to use SecurityManager to prevent unauthorized access to private members of a Java class, for...
