<Item> Reading List with Update from XML API
I am trying to use Retrofit with SimpleXmlConverter to read data from my API.
My Comment class is as follows:
@Root class Comment { @Element private String text; } I would like to read a list of comments from XML:
<comments> <comment> <text>sample text</text> </comment> <comment> <text>sample text</text> </comment> </comments> There is a method in my interface:
@GET("/lastcomments") ArrayList<Comment> lastComments(); but when I call lastComments () Retrofit throws:
Caused by: retrofit.RetrofitError: java.lang.ClassCastException: libcore.reflect.ParameterizedTypeImpl cannot be cast to java.lang.Class ... Caused by: retrofit.converter.ConversionException: java.lang.ClassCastException: libcore.reflect.ParameterizedTypeImpl cannot be cast to java.lang.Class at com.mobprofs.retrofit.converters.SimpleXmlConverter.fromBody(SimpleXmlConverter.java:76) ... Caused by: java.lang.ClassCastException: libcore.reflect.ParameterizedTypeImpl cannot be cast to java.lang.Class at com.mobprofs.retrofit.converters.SimpleXmlConverter.fromBody(SimpleXmlConverter.java:72) Is it possible to read the list directly from the API or do I need to create a wrapper:
@Root(name="comments") class CommentsList { @Element(name="comment", inline=true) List<Comment> comments; } +5