【发布时间】:2015-07-18 18:43:27
【问题描述】:
这是我获得的 XML 示例。它包含更多带有 item 的行
<items>
<item name="Alfa Romeo">
<models>
<model to="2001" since="1994" name="145/146" />
<model since="2001" name="147" />
<model to="1997" since="1992" name="155" />
<model since="1997" name="156" />
<model since="2007" name="159" />
<model to="1998" since="1990" name="164" />
<model since="1999" name="166" />
<model since="2004" name="GT" />
<model since="1996" name="GTV" />
<model to="2007" since="1996" name="Spider" />
<model since="2007" name="Spider" />
</models>
</item>
<item name="Fiat">
<models>
<model since="1995" name="Barchetta" />
<model since="2007" name="Bravo" />
<model since="1995" name="Bravo and Brava" />
<model to="1998" since="1993" name="Cinquecento" />
<model to="2000" since="1995" name="Coupe" />
<model since="2001" name="Doblo" />
<model since="2007" name="Grande Punto" />
<model to="2007" since="2004" name="Idea" />
<model to="2001" since="1997" name="Marea" />
<model since="1999" name="Multipla" />
<model since="2004" name="Panda" />
<model to="2003" since="1994" name="Punto" />
<model since="2003" name="Punto" />
<model to="2004" since="1998" name="Seicento" />
<model since="2002" name="Stilo" />
<model to="1996" since="1991" name="Tempra" />
<model to="1996" since="1989" name="Tipo" />
<model to="2003" since="1995" name="Ulysse" />
</models>
</item>
</items>
是否可以将其解组为具有私有 int 字段的 Model 对象;私人 int 以来;私有字符串名称;包含在 ArrayList 中的 Car(item) 模型中的 ArrayList 中?
或者使用带有私有字符串品牌(名称)字段的 Car 对象;私人 int 以来;私人int; ArrayList 中包含的私有字符串模型(名称)?
如果有怎么办?或者如果不是,我可以通过其他方式将信息检索到对象和数据结构中吗?
我已经开始通过非常基本的教程来学习 JAXB,所以我正在一步一步地到达那里,但我真的希望能够在我正在从事的另一个 java 项目中使用这些 XML 数据尽快。
谢谢。
【问题讨论】: