java - Convert XML to Object xstream ( Android ) -


i'm looking conversion of xml object via xstream , here xml

<main>       <listdto>           <myobject>               <test>value1</test>           </myobject>           <myobject>               <test>value2</test>           </myobject>        </listdto> </main> 

here classes.

public class first{       myobject[] listdto; }  public class myobject{       string test; } 

with xstream :

... xstream xstream = new xstream(); xstream.alias("main",first.class); xstream.alias("listdto", myobject.class); xstream.addimplicitcollection(first.class,"listdto");  .... 

the tag <listdto> problem, , can not change xml . classes generated wsdl eclipse .

can me ?

your code should this:

xstream xstream = new xstream(); xstream.alias("main", first.class); xstream.alias("myobject", myobject.class); 

first, don't have implicit collection, explicit 1 marked listdto tag. implicit collection xml be:

<main>     <myobject>         <test>value1</test>     </myobject>     <myobject>         <test>value2</test>     </myobject> </main> 

and second error have made adding listdto alias myobject class. should replaced myobject alias, since have myobject tag defined in xml corresponds myobject class.


Comments