Skip to main content

XmlSerialization. In the right way?

2 replies [Last post]
jonathanvargas
Offline
Joined: 2005-09-28
Points: 0

Hi,

I am tryng to perform XmlSerialization in the way .NEt platform does using XmlSerializer, and wanted to know how could I perform such task with Java.

I read just a bit about JAXB and I wanted to know if i am putting the hands where they should.

I would like to serialize objects as simple as extending an interface or class and tell to a xml serializer to serialize an object marked as serializable.

It seems that using jaxb i can compile an xsd to generate java source code, and then perform serialization.

But is there not a much simpler process without creating an xml schema and compiling it to java classes? I mean just telling the serializer what type of object one wants to serialize and where to place it (a file for example), as simple as that.

If Jaxb is not for this purpose, could some of u guide me to the correct available APIs (if exist) to simplify these tasks.

Thanks for helping.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
Joined: 2003-06-09
Points: 0

If you want the equivalent of System.Xml.Serialization in Java, you came to the right place, which is JAXB 2.0.

But if you want to just do Java Serialization (with all its java.io.Serializable and readResolve and etc), and to XML instead of binary, JAXB 2.0 isn't going to give you that kind of out-of-box experience.

For those kind of APIs, you should look at libraries like XStream and JSX.

jonathanvargas
Offline
Joined: 2005-09-28
Points: 0

Cool.

At least XStream seems to do what i want. Thank a lot !
:)