Hi Raj,

Raj wrote:

> Hi
> 
> I have spend lot of time but could not create xml like
> 
> How to achieve xml like
> <person>
>   <user fn="Joe"/>
>   <lastname>Walnes</lastname>
> </person>
> 
> If i have person object like
> public class Person {
>   private String firstname;
>   private String lastname;
> }
> 
> The above sample give the output at xml like
> <person>
>   <firstname>Joe</firstname>
>   <lastname>Walnes</lastname>
> </person>
> 
> Code:
> public class Person {
>   private String firstname;
>   private String lastname;
> }
> 
> 
> Person joe = new Person("Joe", "Walnes");
> String xml = xstream.toXML(joe);
> 
>  
> Any help will be appreciated.

You can configure XStream to use an attribute instead of an element, but you 
cannot have both. This is exactly a situation where you have to write an own 
custom converter. Since you've already looked at the tutorial, you should be 
able to write one.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to