Search code examples
javaxml-serializationxml-deserialization

Best Practice for Serialize/Deserialize from Java to XML


What is the most appropriate way to serialize Java Classes to XML? I tried JAXB, but it has issues with Interfaces and Generics. What solution is least intrusive but scalable?


Solution

  • I've always had positive experiences with XStream:

    http://x-stream.github.io/tutorial.html#to-xml

    As you can see, it's simple to use.

    I haven't actually used XStream with Generics (I've only ever used it for simple JavaBean type classes), but Google seems to suggest it handles them without problems. e.g. http://techo-ecco.com/blog/xstream-spring-ws-oxm-and-generics/