Attribute Serialization

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Attribute Serialization

RoshanP
Is there a way to be able to take a class and specify that one field should be an attribute in XML? For example, Person.class would serialize to:

<person firstname="Roshan">
  <lastname>Something</lastname>
</person>

Roshan Punnoose
Phone: 301-497-6039
-----Original Message-----
From: news [mailto:[hidden email]] On Behalf Of Jörg Schaible
Sent: Friday, January 20, 2006 2:24 PM
To: [hidden email]
Subject: [xstream-user] Re: How to serialize XML file

[hidden email] wrote:

>
> Hi,
>
> I have read xstream tutorial.
>
> It serialize the java object to XML.
>
>
>
> But I want to serialize the complete XML file(in form of DOM
> object(Document)) to some Java
>
> Object in Applet and send it to servlet running at server.
XStream does not care of what type your output stream is.

> Later on I want to deserialize this Java object back to XML DOM object
> in Servlet at server side so that
>
> I can parse the XML file.

Well, you will receive an object, if you have deserialized it on the server
side ...

- Jörg



Reply | Threaded
Open this post in threaded view
|

Re: Attribute Serialization

Mauro Talevi
Punnoose, Roshan wrote:
> Is there a way to be able to take a class and specify that one field should be an attribute in XML? For example, Person.class would serialize to:
>
> <person firstname="Roshan">
>   <lastname>Something</lastname>
> </person>
>

Presently, you need to write your own custom Converter.
There are several examples on the list you can base it on.

Cheers