基本上我试图解开这个
<polls xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="polls.xsd">
<poll id="1">
<title>WSD Meeting</title>
<state>Open</state>
<userID>1</userID>
<datecreated>88/88/1996</datecreated>
<location>UTS</location>
<description>Meeting for assignment</description>
<meetings>
<meeting option ='1'>
<time>12:00</time>
<date>99/88/1996</date>
<responses>
<response>John Doe</response>
</responses>
</meeting>
<meeting option ='2'>
<time>12:00</time>
<date>99/88/1996</date>
<responses>
<response>John Doe</response>
<response>John Smith</response>
</responses>
</meeting>
</meetings>
</poll>
</polls>
当我参加会议时,解组会遇到麻烦 这是民意调查班
@XmlAccessorType(XmlAccessType.FIELD)
public class Poll implements Serializable {
@XmlAttribute
private int ID;
private String title;
private int state;
private int userID;
private String datecreated;
private String location;
private String description;
@XmlElement(name = "meetings")
private ArrayList<Meeting> meetings = new ArrayList<Meeting>();
这是会议班
@XmlAccessorType(XmlAccessType.FIELD)
public class Meeting implements Serializable {
@XmlAttribute
private int option;
private String time;
private String date;
@XmlElement(name = "responses")
private ArrayList<Response> responses = new ArrayList<Response>();
基本上来自民意调查的数据正在被编组好(我已经检查了这个)但是一旦它遇到会议就会使列表中的一个条目为空,我错过了什么?
答案 0 :(得分:0)
您似乎错过了会议类(对应于<meetings>
)包装会议实例(对应于<meeting>
)。
如果你使用像XJC这样的工具生成JAXB,那就不会发生这种情况,因此不清楚你是如何在这种情况下结束的(也许你试图自定义一些东西)。但也许这在任何情况下都有帮助。