Simple Xml list parsing problem
- by Hubidubi
I have this xml:
<root>
<fruitlist>
<apple>4</apple>
<apple>5</apple>
<orange>2</orange>
<orange>6</orange>
</fruitlist>
</root>
I'm writing a parser class, although I can't figure out how to deal with multiple node types. I can easily parse a list that contains only one node type (eg. just apples, not oranges)
@ElementList(name = "fruitlist")
private List<Apple> exercises;
with more than one node type it also wants so parse non Apple nodes which doesn't work.
I also tried to make another list for oranges, but it doen't work, I can't use fruitlist name more than once.
@ElementList(name = "fruitlist", entry = "orange")
private List<Orange> exercises;
The ideal would be two seperate list for both node types.
Hubi
EDIT:
After more searching & fiddling this question is a duplicate:
Inheritance with Simple XML Framework