Java JAXB how to create POJO classes

末鹿安然 提交于 2019-12-13 04:53:56

问题


With JAXB, how can I create the POJO classes with such a xml structure :

 <procedure>
    <procedure>
       <param>value1</param>
       <param>value2</param>
    </procedure>
    <procedure>
       <param>value3</param>
       <param>value4</param>
    </procedure>
 </procedure>

As you can see the external procedure tag is the same than the internal procedure tag.


回答1:


What's so special about the outer/inner procedure element names?

Probably something like:

@XmlRootElement(name="procedure")
public class Procedure {
    @XmlElement(name="procedure")
    public List<Params> procedures = new LinkedList<Params>();
}
public class Params {
   @XmlElement(name="param")
   public List<String> params = new LinkedList<String>();
}

Untested.



来源:https://stackoverflow.com/questions/26822077/java-jaxb-how-to-create-pojo-classes

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