Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 简单XML注释问题_Java_Android_Annotations_Retrofit2_Simple Framework - Fatal编程技术网

Java 简单XML注释问题

Java 简单XML注释问题,java,android,annotations,retrofit2,simple-framework,Java,Android,Annotations,Retrofit2,Simple Framework,我正在使用改型来解析来自服务器的响应,我无法看到应该使用什么注释来解决这个问题。我甚至提到过。 什么是正确的方法 以下是我的改装故障日志 failurejava.lang.RuntimeException:org.simpleframework.xml.core.ElementException:Element“route”在类drish.com.dsfaallstars.updatefromserver.model.Routes的第1行中没有匹配项 空的 我收到的XML: <routes

我正在使用改型来解析来自服务器的响应,我无法看到应该使用什么注释来解决这个问题。我甚至提到过。 什么是正确的方法

以下是我的改装故障日志

failurejava.lang.RuntimeException:org.simpleframework.xml.core.ElementException:Element“route”在类drish.com.dsfaallstars.updatefromserver.model.Routes的第1行中没有匹配项 空的

我收到的XML:

<routes>
    <route>
        <id>20</id>
        <name>Barnala</name>
        <update>false</update>
    </route>
    <route>
        <id>15</id>
        <name>Kapurthala</name>
        <update>false</update>
    </route>
    <route>
        <id>14</id>
        <name>Nakodar</name>
        <update>false</update>
    </route>
</routes>

public class Routes {

  @Root
  @ElementList
  private List<Route> routes;
}

@Root(name = "route")
 public class Route{

    @Element(required = false)
    private String id;

    @Element(required = false)
    private String update;

    @Element(required = false)
    private String name;

    public String getId ()
    {
      return id;
    }

    public void setId (String id)
    {
      this.id = id;
    }

    public String getUpdate ()
    {
      return update;
    }

    public void setUpdate (String update)
    {
      this.update = update;
    }

    public String getName ()
    {
      return name;
    }

    public void setName (String name)
    {
      this.name = name;
    }
  }

20
巴尔纳拉
假的
15
卡普塔拉邦
假的
14
中田
假的
公务舱路线{
@根
@元素列表
私人名单路线;
}
@Root(name=“route”)
公务舱路线{
@元素(必需=false)
私有字符串id;
@元素(必需=false)
私有字符串更新;
@元素(必需=false)
私有字符串名称;
公共字符串getId()
{
返回id;
}
公共无效集合id(字符串id)
{
this.id=id;
}
公共字符串getUpdate()
{
返回更新;
}
公共无效设置日期(字符串更新)
{
this.update=更新;
}
公共字符串getName()
{
返回名称;
}
公共void集合名(字符串名)
{
this.name=名称;
}
}
@Element(name=“routes”)
@订单(elements=“route”)
公务舱路线{
@元素列表(entry=“route”,inline=true)
私有列表路由;
@凌驾
公共字符串toString(){
返回“路由{”+
“路线=”+路线+
'}';
}
}
公共类RoutePojo{
@元素(必需=false)
私有字符串id;
@元素(必需=false)
私有字符串更新;
@元素(必需=false)
私有字符串名称;
公共字符串getId()
{
返回id;
}
公共无效集合id(字符串id)
{
this.id=id;
}
公共字符串getUpdate()
{
返回更新;
}
公共无效设置日期(字符串更新)
{
this.update=更新;
}
公共字符串getName()
{
返回名称;
}
公共void集合名(字符串名)
{
this.name=名称;
}
@凌驾
公共字符串toString(){
返回“RoutePojo{”+
“id=”+id+“\”+
,update=''+update+'\''+
“,name=”“+name+”\“””+
'}';
}
}
接受了来自
@Element(name = "routes")
@Order(elements = "route")
public class Routes {

  @ElementList(entry = "route",inline = true)
  private List<RoutePojo> route;

  @Override
  public String toString() {
    return "Routes{" +
        "route=" + route +
        '}';
  }
}



public class RoutePojo{

    @Element(required = false)
    private String id;

    @Element(required = false)
    private String update;

    @Element(required = false)
    private String name;

    public String getId ()
    {
      return id;
    }

    public void setId (String id)
    {
      this.id = id;
    }

    public String getUpdate ()
    {
      return update;
    }

    public void setUpdate (String update)
    {
      this.update = update;
    }

    public String getName ()
    {
      return name;
    }

    public void setName (String name)
    {
      this.name = name;
    }

  @Override
  public String toString() {
    return "RoutePojo{" +
        "id='" + id + '\'' +
        ", update='" + update + '\'' +
        ", name='" + name + '\'' +
        '}';
  }
}