我正在尝试使用org.simpleframework.xml。用于处理Android项目中的xml数据的类。我无法理解如何建立我的班级" ChecklistGradeDetail"但我得到了这个
01-09 14:56:05.615: WARN/System.err(896): org.simpleframework.xml.core.PersistenceException: Element 'ChecklistGradeDetail' declared twice at line -1
XML /休息
<ArrayOfChecklistGradeDetail xmlns="http://schemas.datacontract.org/2004/07/TeamTask.Service" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ChecklistGradeDetail>
<ChecklistItemID>34</ChecklistItemID>
<ChecklistItemText>requirements</ChecklistItemText>
<Comments>please pass</Comments>
<CreatedOn>2011-09-07T16:30:08.14</CreatedOn>
<GradeDetailID>362</GradeDetailID>
<NotPerformed>false</NotPerformed>
<Preceptor>System Administrator</Preceptor>
<Satisfactory>true</Satisfactory>
<Unsatisfactory>false</Unsatisfactory>
<UserID>admin</UserID>
</ChecklistGradeDetail>
<ChecklistGradeDetail>
<ChecklistItemID>35</ChecklistItemID>
<ChecklistItemText>write test</ChecklistItemText>
<Comments>please pass</Comments>
<CreatedOn>2011-09-07T16:30:08.14</CreatedOn>
<GradeDetailID>363</GradeDetailID>
<NotPerformed>false</NotPerformed>
<Preceptor>System Administrator</Preceptor>
<Satisfactory>true</Satisfactory>
<Unsatisfactory>false</Unsatisfactory>
<UserID>admin</UserID>
</ChecklistGradeDetail>
<ChecklistGradeDetail>
<ChecklistItemID>36</ChecklistItemID>
<ChecklistItemText>execute test</ChecklistItemText>
<Comments>please pass</Comments>
<CreatedOn>2011-09-07T16:30:08.14</CreatedOn>
<GradeDetailID>364</GradeDetailID>
<NotPerformed>false</NotPerformed>
<Preceptor>System Administrator</Preceptor>
<Satisfactory>true</Satisfactory>
<Unsatisfactory>false</Unsatisfactory>
<UserID>admin</UserID>
</ChecklistGradeDetail>
</ArrayOfChecklistGradeDetail>
ArrayofChecklistGradeDetail类
@Root
public class ArrayOfChecklistGradeDetail {
@ElementList(name="ChecklistGradeDetail")
public ArrayList<ChecklistItems> Checklist;
}
ChecklistItem类
public class ChecklistItems {
@Element(required=false)
public String ChecklistItemID;
@Element(required=false)
public String ChecklistItemText;
@Element(required=false)
public String Comments;
@Element(required=false)
public String CreatedOn;
@Element(required=false)
public String GradeDetailID;
@Element(required=false)
public String NotPerformed;
@Element(required=false)
public String Preceptor;
@Element(required=false)
public String Satisfactory;
@Element(required=false)
public String Unsatisfactory;
@Element(required=false)
public String UserID;
}
帮助:(
答案 0 :(得分:3)
我弄明白了这个问题。 ArrayofCheclistGradeDetail类需要如下
@Root
public class ArrayOfChecklistGradeDetail {
@ElementList(entry="ChecklistGradeDetail", inline=true)
public ArrayList<ChecklistItems> Checklist;