I have XML in this format:
<element1>
some inner text
<child1>11</child1>
<child2>True</child2>
</element1>
And I try to map this XML on object by simple framework:
@Element(name = "element1")
public static class Something {
@Element(required=false)
public int child1;
@Element(required=false)
public boolean child2;
}
I can’t change the XML and I need to map also value “some inner text” on some field in class. Unfortunatelly I don’t know how to do that (and if it is possible). I tried @Text annotation but it can’t be used together with @Element in one class.
Thanks for any help.
EDIT: You can actually do this with version 2.6.9 and up. Use the following annotations, note the
@Textannotation can be used with@ElementListUnion.This can only be done as a hack job, by default simple does not support free text as it does not map consistently to an object. Here is how you can do it, however its probably not worth it unless this is a special case within a large file of cases that work well in Simple.