I have the following problem, with JAXB library.
XML
<par>
<name>content</name>
<value>This is a value</value>
</par>
<par>
<name>map</name>
<value>
<info>
<obj>obj1</obj>
</info>
</value>
</par>
Class Java
public static class Par {
@XmlElement(name = "name")
private String name;
@XmlElement(name = "value")
private Info valueObject;
@XmlAnyElement(lax = true)
private Node valueString;
}
public static class Info {
@XmlElement(name = "obj")
private String obj;
}
the problem is that the Info field is mapped correctly, so in the value valueObject i have the full object Info. But the string This is a value is not mapped, because JAXB library maps only the first field called "value".
What can I do to map the value string?
I found on StackOverflow one similar question, but in the response they said to use the object Node (DOM library). So, the field is treated as a String, and in a second moment they used another time the JAXB library to map the complex Object. So, this is not a good solution for my script because I have a list of string and a list of object; then, if the list is very long I will have to read the list.
What can I do ? Can you help me ?
Thanks a lot