xml:
<root>
<element>value (something)</element>
</root>
I need to unmarshall this xml to two different fields in my java class.
I tried the following but it didn’t work. the first field had the right value and the second one was null.
java:
@XmlElement(name="element")
@XmlJavaTypeAdapter(TakeValueBeforeParentheses.class)
private String one;
@XmlElement(name="element")
@XmlJavaTypeAdapter(TakeValueInParentheses.class)
private String two;
How can I achieve this without creating a class to hold both values and map that to “element”?
You may annotate setters and not fields, and then make setter parse value to two fields: