XML : How to change XML Output/Format with Annotations in XStream?

I'm currently working with XStream, but still don't get exactly how the annotations and alias tags works.

I have an output like that:

  <object-stream>   <Produkt id="1" preis="22.22" name="test12" anzahl="22"/>  </object-stream>    

but my desired output would be like:

  <Class>   <Produkt id="000001">     <name>.. </name>     <preis> 22.22 </preis>   </Produkt>   <Produkt id="000002">    ...   </Produkt>    

How can I manage these?

My code with annotations looks like:

  @XStreamAlias("Produkt")  public class Produkt implements  java.io.Externalizable {    @XStreamAlias("id")  @XStreamAsAttribute()  @XStreamConverter(Converter.class)  private long id;  ... }    

Thanks a lot :)

No comments:

Post a Comment