Closed forceporquillo closed 1 year ago
No, that's not how XML Text works -- you cannot arbitrarily claim to not parse XML elements and leave them as "general XML content". If there is element <test>
, it must match structure; XML parser will (and must) decode it separately into elements, text segments and so on.
Put another way, @JacksonXmlText
can only map XML text segments (text within element), not for XML sub-trees.
You could bind it into
private Object content;
or
private JsonNode content;
in which case contents would be read into Map
s or JsonNode
.
Thanks for your clarifications and insights! I was able to resolve it by following your suggestion and reading the contents via JsonNode
. Closing this issue.
@forceporquillo I am glad work-around works for you -- good luck!
Given a POJO, I should be able to deserialize any element value from an XML element.
suppose, this object:
When deserializing a value from an XML element, note: that the value from that element is wrapped inside an XML element.
The expected value of
matchingGroups.getContent()
should be<test>1</test>
however, in my case it was empty.I am aware that the docs say: Allows specifying that value of one property is to be serialized as "unwrapped" text, and not in an element.
I am using the 2.13.4 version. Is there a way how we can easily achieve retrieving a wrapped text from an XML element?