I am trying to parse XML that has several "Fields" elements to different class members according to one of their attributes. Here is the XML:
<Series>
<Fields type="SelectedFields" operation="SUM">
<Field name="Remaining" />
<Field name="Invested" />
</Field>
<Fields type="FirstSelectedFields" operation="SUM">
<Field name="Estimated" />
</Field>
</Series>
And here is the java class it should be mapped to:
public class APMSeries {
private List<Field> selectedFields;
private List<Field> firstSelectedFields;
}
Can anyone tell me how can I set the Fields element with attribute type="SelectedFields" to the selectedFields member and the Fields element with the attribute type="FirstSelectedFields" to the firstSelectedFields member?
public class APMSeries {
@XmlElementWrapper(name="SelectedFields")
private List<Field> selectedFields;
@XmlElementWrapper(name="FirstSelectedFields")
private List<Field> firstSelectedFields;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.