Say I have the following XML and Java code respectively:
<foo>
My text content
</foo>
@XmlRootElement( name="foo" )
public static class Foo
{
// This is where I want to see "My text content" stored
private String text;
// getters and setters
}
When I tried marshalling the XML, my Foo
instance doesn't get its text property populated with value from the inner text of my foo
element in the given XML. How do I solve this?
You can use the
@XmlValue
annotation.For More Information