I have some xml data I'm trying to unmarshall into java objects and one of the elements contains <br/> elements:
<details>
<para>
Line Number One
<br/>
Line Number Two
</para>
</details>
In my Details java object I have:
class Details {
@XmlElement(name="para")
private List<String> paragraphs;
}
The problem is that the only element in the paragraphs list is 'Line Number Two'. Does anyone know how I can deal with this?
You can represent mixed content with @XmlMixed as follows (note that it's applied to content of a class itself rather than to its element, thus you need an additional class):
class Details {
@XmlElement(name="para")
private Para para;
...
}
class Para {
@XmlMixed
@XmlAnyElement
private List<Object> paragraphs;
...
}
paragraphs property will contain Strings for text lines and Elements for XML elements.
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