A substring of my XML looks like this:
<foo value1="a" value2="b">value3</foo>
I'm trying to parse this using JAXB. I've managed to parse the values value1 and value2 but I'm having problems with the "root" value since it doesn't have any tag associated with it.
My class:
@XmlType(propOrder = {"value3"}, name = "foo")
@XmlAccessorType(XmlAccessType.FIELD)
public class Foo
{
@XmlAttribute
private String value1;
@XmlAttribute
private String value2;
@XmlElement(name = "")
private String value3;
}
Any ideas?
You can use the @XmlValue
annotation:
@XmlAccessorType(XmlAccessType.FIELD)
public class Foo
{
@XmlAttribute
private String value1;
@XmlAttribute
private String value2;
@XmlValue
private String value3;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With