Retrofit - 使用SimpleXmlConverterFactory解析XML元素列表

时间:2016-11-14 15:28:21

标签: android xml arraylist retrofit2 simple-xml-converter

从服务器返回的XML内容:

<root> <option value="ROW VALUE1">ROW CONTENT1</option> <option value="ROW VALUE2">ROW CONTENT2</option> </root>

我对option对象的表示:

public class Option {
    @Element(name = "option")
    private String option;

    @Attribute(required = false)
    private String value;
}

我对Response对象的表示:

@Root(name = "root")
public class GetOptionsResponse
{
    @ElementList(entry = "option", inline = true)
    private ArrayList<Option> mOptionList;
}

但是无论何时我试图运行代码并解析它,我得到了:

java.lang.RuntimeException: org.simpleframework.xml.core.ValueRequiredException: Unable to satisfy @org.simpleframework.xml.Element(data=false, name=option, required=true, type=void) on field 'option' private java.lang.String com.packagename.models.Option.option for class com.packagename.models.Option at line 1

我做错了什么?

0 个答案:

没有答案