我必须像这样解析xml响应:
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member>
<name>RESULT_CODE</name>
<value>
<array>
<data>
<value>SUCCESS</value>
</data>
</array>
</value>
</member>
<member>
<name>MEMBER_KEY</name>
<value>de1cc72569709126282f76cca4c1111a3813c131</value>
</member>
<member>
<name>TEMP_HOLD_TIME</name>
<value>12</value>
</member>
</struct>
</value>
</param>
</params>
</methodResponse>
在我的Android项目中,我使用compile('com.squareup.retrofit2:converter-simplexml:2.0.0-beta4')
并制作这样的模型
public class Response {
@Element
public Params params;
public static class Params {
@Element
public Param param;
}
public static class Param {
@Element
public Value value;
}
public static class Value {
@Element
public Struct struct;
}
public static class Struct {
@Element
public Member member;
@ElementList(required = false, inline = true)
public List<Member1> members;
}
public static class Member {
@Element
public String name;
@Element
public Value1 value;
}
public static class Value1 {
@Element
public Array array;
}
public static class Array {
@Element
public Data data;
}
public static class Data {
@Element
public String value;
}
public static class Member1 {
@Element
public String name;
@Element
public String value;
}
}
我的请求是成功的但是在解析数据时,我收到了错误
java.lang.RuntimeException: org.simpleframework.xml.core.PersistenceException: Element 'member' is already used with @org.simpleframework.xml.Element(data=false, name=, required=true, type=void) on field 'member' public Response$Member Response$Struct.member at line 2
我不确定Struct类。如何使它正常? 感谢您的帮助