[SOLVED] How to get nested elements with JacksonXmlRootElement?

Issue

I am using Java/Spring

I have XML like this:

 <Transfer> 
 <Data>
     ... 
 </Data>
 <Transfer>

and I just need to access to XML element "Data" for my model, like:
@JacksonXmlRootElement (localName = "Data")

Is it possible without additional wrapper class?

Solution

Friendly reminder to everyone: please don’t mix-up JAXB with JacksonXML. All my problems were from there.

Just add an additional model, like in code below:

@Data
@JacksonXmlRootElement(localName = "Transfer")
public class WrapperClass{

   @JacksonXmlProperty(localName="Data")
   public MyClass myClas;

}

Answered By – Юрій

Answer Checked By – Terry (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.