I’ve inherited a project which uses JAXB heavily to map XML messages onto Java objects. The problem I have is that some of the data which I receive (in this case nested XML of unknown form) has NOT to be unmarshalled, rather captured as a String.
An example will help
<a>
<b></b>
<c></c>
<d>
<!-- "Unknown" XML here -->
<maybeE></maybeE>
<maybeF></maybeF>
<!-- etc etc -->
<d/>
</a>
So I would want the JAXB to unmarshall “b” and “c” but “d” it would capture the nested XML as a string i.e. not parsed.
So calling:
getD()
Would return string:
"<maybeE></maybeE><maybeF></maybeF>"
You can’t capture the nested content as a String, but you can capture it as a DOM, e.g.
Whatever
<a>contains, which does not match<b>or<c>, will be stored undercontent. You can then convert thoseElementobjects into Strings, if you so wish.