5
我想使用簡單的XML框架。但我正在逐漸ValueRequiredExceptionValueRequired異常雖然使用簡單的XML框架
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>
我的註釋類如下所示:
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;
}
可能是什麼問題?如何解決它?