janvan777
janvan777

Reputation: 3

Java JAXB xml pojo classes

How can I create the POJO classes with JAXB with such a xml structure :

<principale>
   <procedure>
      <procedure>
         <param1>value1</param1>
         <param2>value2</param2>
      </procedure>
      <procedure>
         <param1>value3</param1>
         <param2>value4</param2>
      </procedure>
   </procedure>
</principale>

As you can see the first procedure tag is not the root one and is the same than the second procedure tag.

Upvotes: 0

Views: 503

Answers (1)

lexicore
lexicore

Reputation: 43671

If the outer procedure element is not repeatable, try it with @XmlElementWrapper:

@XmlRootElement(name="principale")
public class Principale {
    @XmlElementWrapper(name="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.)

Upvotes: 1

Related Questions