Ihor M.
Ihor M.

Reputation: 3148

JAXB how to annotate mixed type of nested element?

I have following sample xml:

 <section name="section_name_1" attribute_1="value">
        <param name="name_1">some text goes here</param>
        <param name="name_2"><some_tag_here_1/></param>
        <param name="name_3"><some_tag_here_2/></param>
 </section>

So, as you can see param tag may contain either arbitrary nested tag or text value.

I tried various combination of @XmlAnyElement, @XmlMixed and @XmlValue. No luck so far. I would appreciate any help here.

Upvotes: 1

Views: 137

Answers (1)

Ihor M.
Ihor M.

Reputation: 3148

Alright, I figured it out:

@XmlMixed
@XmlAnyElement
private List nestedObject = null;

Upvotes: 1

Related Questions