如何在不映射根xml元素的情况下解组xml? [英] How to unmarshal xml without mapping the root xml element?

查看:102
本文介绍了如何在不映射根xml元素的情况下解组xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要解组包含数据集合的xml文件,例如

I want to unmarshal a xml file containing a collection of data, like this

 <Persons>
      <Person>Jim</Person>
      <Person>Tom</Person>  
  </Persons>

我们知道这可以通过两个classess完成:人员,使用Castor的人员,JAXB或其他框架。

We know this can be done with two classess: Persons, Person using Castor , JAXB, or other frameworks.

但是如何不编写集合类人员?

But how to do without writing a collection class Persons ?

推荐答案

寻找一种方法告诉Castor您希望它生成一个 java.util.List 的Person实例。

Look for a way to tell Castor that you'd like it to generate a java.util.List of Person instances.

http://www.castor.org /how-to-map-a-list-at-root.html

这篇关于如何在不映射根xml元素的情况下解组xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆