I chose JAXB for my XML serialization/deserialization beacuse I had an XML schema already and wanted XML in a way which JAXB provided being a native XML library. Even though Jackson xml is a good choice too if it suits your needs.
Limitations of the Jackson XML Module:
The XML module in Jackson is by no means designed to be an exact replacement for JAXB. There are certain constructs that will work subtly differently between JAXB and Jackson, and there is no guarantee that Jackson will produce identical XML to JAXB.
Note that, unlike with JSON, the outermost object must be a bean type – it can not be a primitive or wrapper type, an enumeration, or a collection. This is a direct result of how XML works – there’s no way in XML to represent such a top-level value.
By default, Jackson will always use a wrapper element for collections, which is also different to how JAXB works. This is the major way that the XML produced by Jackson is not compatible with the XML produced by JAXB. Of course, the behavior can be configured, using the JacksonXmlElementWrapper annotation for one field or the setDefaultUseWrapper configuration setting on the XmlMapper globally.
Jackson also has no support for working with specific XML Schemas. It’s designed for writing Java Beans first, rather than generating the Java code from pre-existing schemas. Note that this can be solved to an extent by using the JAXB annotation support and generating the beans using the standard xjc tool.
Equally, it has no support for some of the more advanced XML tools – such as XPath or XSLT. If we need this level of support then we should instead use a more full-featured XML solution.
Summary:
If you’re looking for a mature, flexible way of supporting and working with both JSON and XML for the same data, the Jackson XML module is a fantastic library to leverage. It’s not only a solid way to go on its own, but it also has the added benefit of being able to mostly reuse the same configuration for both XML as well as JSON.
Typically, this has to be handled using two different libraries with entirely separate configurations.
Finally, beyond flexibility and ease-of-use, the Jackson team has historically placed a strong emphasis on performance. And given that marshalling and unmarshalling of data is a large part of most web applications, choosing the right library to handle all of that work is critical. That, plus a performance monitoring tool such as Retrace will allow you to get the most out of your app.
References: https://stackify.com/java-xml-jackson/