Borodin.Mik
Borodin.Mik

Reputation: 332

Jaxb tag embedded in tag

I have XML like this:

   <FirstTag Attr="123">
     <WrapperTag>
       <EmbeddedTag>
       ....
       </EmbeddedTag>
     </WrapperTag>
   </FirstTag>

and code:

class FirstTag{
    EmbeddedTag tag;
}

i dont want write WrapperTag's class. What annotation should I use for EmbeddedTag?

Upvotes: 1

Views: 647

Answers (1)

Joe
Joe

Reputation: 115

You will need to use:

@XmlRootElement(name = "FirstTag")

above your first class, and then use:

@XmlElementWrapper(name="Wrapper")
@XmlElement(name="Embedded Tag")

above your variables which you want as a wrapper and embedded.

Hope this helps.

Upvotes: 1

Related Questions