I need to annotate a class for unmarshalling an XML like this:
<element>data</element>
And I don’t know how to do it because the class has to be annotated with @XmlRootElement but I need to get the root element value. I know this doesn’t work but it’s what I have done:
@XmlRootElement(name = "element")
public Class MyClass{
@XmlElement(name = "element")
protected String elementValue;
public String getElementValue(){...}
public void setElementValue(String el){...}
Is there any possibility to get this?
You are looking for the
@XmlValueannotation.MyClass
Demo
Output