Reputation: 299
How can I rearrange my xml elements from:
- <course>
- <CourseType>
- <GroupIndex>
<index>1</index>
<professor>James</professor>
</GroupIndex>
<classType>Lecture</classType>
</CourseType>
<courseCode>3000</courseCode>
</course>
To:
- <course>
<courseCode>3000</courseCode>
- <CourseType>
<classType>Lecture</classType>
- <GroupIndex>
<index>1</index>
<professor>James</professor>
</GroupIndex>
</CourseType>
</course>
It's about how to arrange them such that elements that cant be expanded will always be above those that can be expanded.
I'm using JAXB marshalling in java to convert my objects to produce the xml file.
Upvotes: 3
Views: 164
Reputation: 2390
Using a proporder in the class you are unmarshalling should help with this issue
e.g.
@XmlType(propOrder = {
"courseCode",
"CourseType"
})
note: when using a propOrder all elements in the object must be added to the propOrder.
Upvotes: 5