6

I am developing an Android app using Retrofit.

The server is sending XML as a response. So I should convert it. In the case of the Json, I used the GsonConverter. And for XMl, I think I can use SimpleXMLConverter.

I visited the GitHub link for SimpleXMLConverter: https://github.com/square/retrofit/tree/master/retrofit-converters/simplexml

And I found this message:

Deprecated – Please switch to the JAXB Converter

So I visited the Github link for JAXBConverter: https://github.com/square/retrofit/tree/master/retrofit-converters/jaxb

But I found this message:

Note that JAXB does not work on Android.

Hmm... what xml converter should I used?...

yoonhok
  • 2,575
  • 2
  • 30
  • 58

2 Answers2

10

I was facing the same issue, but Jake Wharton came to the rescue.
(https://github.com/square/retrofit/issues/2733)

Tickaroo TikXML can be used as an alternative
add the following dependencies

implementation 'com.tickaroo.tikxml:annotation:0.8.15'
implementation 'com.tickaroo.tikxml:core:0.8.15'
implementation 'com.tickaroo.tikxml:retrofit-converter:0.8.15'

annotationProcessor 'com.tickaroo.tikxml:processor:0.8.15'

(if you have problems with the version you can use 0.8.13)

After you've synced your project you're able to use the TikXML converter factory like so:

 Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_URL)
                .addConverterFactory(TikXmlConverterFactory.create())
                .build();

The read me documentation of TikXML is pretty straight forward and can be found here: https://github.com/Tickaroo/tikxml/blob/master/docs/AnnotatingModelClasses.md

But if you need more help please let me know

Alexander
  • 257
  • 1
  • 9
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/21827216) – Ade Stringer Jan 02 '19 at 18:32
  • My bad, Should have read the guidelines first. So thanks for the clarification, I've updated my answer accordingly – Alexander Jan 02 '19 at 19:59
  • Unfortunately, TikXml proceeds with UTF-8 encoding only, wheras SimpleXML worked with others old encoding :( – QLag Nov 23 '20 at 13:14
  • I also need to add processor-common to generate TypeAdapter – Mia May 31 '23 at 06:32
0

Please try SimpleXMLConverter even if it is deprecated

free
  • 1
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 21 '22 at 01:30