L
L
Light7772020-06-25 07:05:45
Java
Light777, 2020-06-25 07:05:45

What is the best method for (de)marshaling xml in Java?

What is the best method for (de)marshaling xml to Java to work with services? There are many ways of jackson, jaxb, pojo and so on on the Internet. What is the difference and what is better, I did not understand

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmtm, 2020-06-25
@Dmtm

judging by the question,
first here - https://habr.com/en/post/64012/
then - here - https://habr.com/en/post/116830/

A
Alexey Cheremisin, 2020-06-25
@leahch

It all depends on the volume of the xml itself. If they are small and fit into memory, then everything is very simple - through ObjectMapper and jackson. Just this method is well suited for POJO classes with annotations.
If you write your own service - abandon XML, go to JSON!
Well, if you accidentally need to parse Wikipedia back and forth, you will have to mess around with StAX / SAX a little. Then we read the parser. We write the pieces through the same jackson, for example.
Well, here it is - https://habr.com/en/post/339716/
Actually, it's better to forget about XML , and use json/json-schema/avro/protobuf/grpc/kryo, but it all depends on the task. You can't get away from XML if you need to communicate with a harsh furry enterprise - I sympathize, and if it's SOAP, then look towards Apache CXF! I sympathize again!
Depending on the task, you can use props from spring and/or even apache camel.
In general, announce the problem in more detail, and the answer will be more specific.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question