How to have multiple sections with the same name in JAXB?

别等时光非礼了梦想. 提交于 2019-12-24 06:37:48

问题


I am using EclipseLink Moxy as my JAXB provider and presently facing issues in getting the XML marshalled in an expected fashion.

I presently have an object which is having multiple objects.

Object 1 having 
@XmlElement(name="Section")
Object2

@XmlElement(name="Section")
Object3

I want to get the XML rendered as:

<Object1>
  <Section>
     <Object2>...
  </Section>
  <Section>
     </Object3>...
  </Section>
</Object1>

I am using Moxy but I am not able to get the desired result. I tried creating a list of objects

@XmlElement(name="Section")
List<Object> sectionsList = new Array<Object>();

but this gives me the object path and not the expected XML. Can someone please help ?

来源:https://stackoverflow.com/questions/39526938/how-to-have-multiple-sections-with-the-same-name-in-jaxb

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!