Reputation: 2733
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?
Upvotes: 2
Views: 1453
Reputation: 149017
You can use the @XmlValue
annotation.
@XmlValue
public String getText() {
return text;
}
For More Information
Upvotes: 3