【发布时间】:2015-12-29 18:43:04
【问题描述】:
我无法弄清楚如何为 simplexml 创建 POJO 模型。
假设我有一个要从中提取数据的 xml,如下所示:
<root>
<station>
<station>
<abbr>Abbr1</abbr>
</station>
</station>
<station>
<station>
<abbr>Abbr2</abbr>
</station>
</station>
<station>
<station>
<abbr>Abbr3</abbr>
</station>
</station>
</root>
所以基本上我认为我在一个数组中有一个数组,所以我像这样编写了我的 java 模型:
@org.simpleframework.xml.Root(name="root")
public class Root {
@Element(name="stations")
public Stations stations;
@Element(name="station")
public Station[] station;
@Element(name="abbr")
public String abbr;
public class Stations{
public Station[] station;
}
public class Station{
public String abbr;
}
}
我尝试调整注释,但无法正常工作。非常感谢您的帮助,谢谢。
【问题讨论】:
-
您的第三行显示
@Element(name="stations"),但您的XML 中没有stations[复数] 元素。他们都说只是station[单数]。
标签: android xml retrofit simple-framework