views:

194

answers:

3

Is there any open source Object to XML serializer in Java that uses writeObject method on the object to serialize similar to NSXMLOutputStream in WebObjects?

+2  A: 

Not sure exactly what you are asking, but I would suggest you look at JAXB, one great Java standard for XML serialization.

Most of the serialization can be defined using annotations, but you can provide your own serialization as well using so-called adapters.

You can then marshall/unmarshall from/to XML as you want. See this answer for an example.

ewernli
+2  A: 

Take a look at XMLEncoder/XMLDecoder classes, which behave like obejct serialization in XML.

These classes are part of the JDK since its 1.4 version.

Riduidel
Voting for that one since it's a core API; I do however agree that there are numerous 3rd party implementations which also do quite well.
dimitko
+2  A: 

Take a look at http://xstream.codehaus.org/ though I don't know if it use those methods on the class Object.

What do you want to use those methods?

damian
Thanks for the suggestion. XStream worked wonderfully for me!
Jason Nichols