I need to deserialize XML in the following format:
<foo>
<field1>
<value>ABC</value>
<text>A B C</text>
</field1>
<field2>
<value>DEF</value>
<text>D E F</text>
</field2>
<field3>1234</field3>
</foo>
Note that field1
and field2
are different types that implement a common interface. This class does not represent a list.
I don't actually care about the <value>
elements, and so want to simply ignore them and use the value of the <text>
elements as the fields value. The intention is to then deserialize the above XML into a type that looks like:
public class FooSimple {
private String field1; // holds value of field1.text element
private String field2; // holds value of field2.text element
private int field3;
// constructor and getters
}
How can this be done? I want to avoid changing FooSimple
to include fields that directly map to the XML.