我正在尝试使用 Simple-XML-framework。但我得到 ValueRequiredException
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 'Employees' public java.util.List com.example.xmlparsing.Company.Employees for class com.example.xmlparsing.Company at line 2
我的 XML 文件具有以下内容:
<?xml version="1.0" encoding="utf-8"?>
<Company>
<Emp>
<Name>Venkat</Name>
<ID>661511</ID>
</Emp>
<Emp>
<Name>Shiv</Name>
<ID>661311</ID>
</Emp>
</Company>
我的注释类如下:
公司.java:
package com.example.xmlparsing;
import java.util.List;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
@Root
public class Company {
@ElementList
public List<Emp> Employees;
}
Emp.java:
package com.example.xmlparsing;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import org.simpleframework.xml.Text;
@Element(name="Emp")
public class Emp {
@Element
public String Name;
@Element
public String ID;
}
可能是什么问题呢?如何解决?