3

sBefore starting a project I wanted to get a short heads up here.

If I have a structure like this:

<root>
<a>
    <a>
        <a>
            <a>
                <a/>
            </a>
        </a>
    </a>
    <a>
    </a>
</a>

The a element can hold a elements and this endlessly deep.

Do I just write a class A and then give it a List as a member? JAXB does the magic automatically then? Or is this structure not possible?

Franz Kafka
  • 10,623
  • 20
  • 93
  • 149

1 Answers1

4

Yes you can have the following:

@XmlAccessorType(XmlAccessType.FIELD)
public class A {

    private List<A> a;

}

And your JAXB (JSR-222) implementation will marshal it correctly.

Related Example

Community
  • 1
  • 1
bdoughan
  • 147,609
  • 23
  • 300
  • 400