java - Read XML using XStream -
how write java class read xml file
<response> <models make="samsung"> <modelno>ab0-12343</modelno> <modelno>bb1232222</modelno> </models> <models make="panasonic"> <modelno>ab0-12343</modelno> <modelno>bb1232222</modelno> </models> </response>
i tried
@xstreamalias("response") public class sl_lookupmodelsresponse { private arraylist<models> models; public arraylist<models> getmodels() { return models; } public void setmodels(arraylist<models> models) { models = models; } @override public string tostring() { return "sl_lookupmodelsresponse [models=" + models + "]"; } @xstreamalias("models") class models{ private arraylist<string> modelno; @xstreamasattribute private string make; public arraylist<string> getmodelnos() { return modelno; } public void setmodelnos(arraylist<string> modelno) { this.modelno = modelno; } public string getmake() { return make; } public void setmake(string make) { this.make = make; } @override public string tostring() { return "models [modelno=" + modelno + "make="+ make +"]"; } } }
but im getting error
exception in thread "main" com.thoughtworks.xstream.converters.conversionexception: modelno : modelno ---- debugging information ---- message : modelno cause-exception : com.thoughtworks.xstream.mapper.cannotresolveclassexception cause-message : modelno class : java.util.arraylist required-type : java.util.arraylist converter-type : com.thoughtworks.xstream.converters.collections.collectionconverter path : /response/models/modelno class[1] : com.samples.sl_lookupmodelsresponse converter-type[1] : com.thoughtworks.xstream.converters.reflection.reflectionconverter version : null
please me on how solve this...
thank you..
i see example here reading complex xml data... helped me lot solve issue. hope helps me..
Comments
Post a Comment