我正在使用Simple XML库:http://simple.sourceforge.net/home.php
我的问题在于@ElementList注解:如果我像这样使用该注解:
@ElementList
protected List<Element> elements;
我的 XML 文件有一个额外的属性:
<elements class="java.util.ArrayList">
如何删除属性 class="....."
?
我正在使用Simple XML库:http://simple.sourceforge.net/home.php
我的问题在于@ElementList注解:如果我像这样使用该注解:
@ElementList
protected List<Element> elements;
我的 XML 文件有一个额外的属性:
<elements class="java.util.ArrayList">
如何删除属性 class="....."
?
class
属性告诉Simple使用哪个List
实现。如果缺少该属性,Simple将自行查找合适的类。
一种解决方案是使用ArrayList
代替List
:
@ElementList
protected ArrayList<Element> elements;
现在Simple不会添加class属性。
另一种方法:
@Path("elements")
@ElementList(inline=true)
protected List<Element> elements;
这会将你的List内联(不使用元素标签),但将它放入一个“新的”元素标签中。