我正在使用 simplexml 解析从网络中获取数据。在解析它时显示以下错误。
错误:
org.simpleframework.xml.core.ValueRequiredException: Unable to satisfy @org.simpleframework.xml.ElementList(data=false, empty=true, entry=, inline=false, name=, required=true, type=void) on field 'jobs' private java.util.List com.example.simpledataparsing.JobList.jobs for class com.example.simpledata.line2
xml文件:
<?xml version="1.0" encoding="UTF-8" ?>
<joblist>
<job><id>75027</id><status>OPEN</status><customer>Manikandan</customer><address>asdf</address><city>salem</city><state>tn</state><zip>636005</zip><product>pipe</product><producturl></producturl><comments>asdf</comments></job>
</joblist>
pojo 类:JobList.java
package com.example.simpledataparsing;
import java.util.List;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
@Element (name="joblist")
public class JobList {
@ElementList
private List<Job> jobs;
public List<Job> getJobs() {
return jobs;
}
public void setJobs(List<Job> jobs) {
this.jobs = jobs;
}
}
作业.java
package com.example.simpledataparsing;
import org.simpleframework.xml.Element;
@Element (name = "job")
public class Job {
@Element
private int id;
}