2
private Retrofit mRetrofit = new Retrofit.Builder()
.baseUrl("http://www.w3schools.com")
.addConverterFactory(SimpleXmlConverterFactory.create())
.build();
Service-Klasse
public interface Food{
@GET("/xml/simple.xml")
Call<List<FoodId>> getFoodIdType();
}
Modellklasse
mit@Root(name = "Food")
public class Food{
@Element(name = "id")
private int id;
@Element(name = "description")
private String description;
public Food(){
}
}
Gradle Config
compile 'com.squareup.retrofit2:retrofit:2.0.0'
compile ('com.squareup.retrofit2:converter-simplexml:2.0.0') {
exclude module: 'stax'
exclude module: 'stax-api'
exclude module: 'xpp3'
}
Randbemerkung: ich in der Lage war, um es mit GsonConverterfactory funktioniert, wenn eine andere URL verwendet.
Ändern von @Root (name = "Food") zu @Root (name = "food") könnte helfen .... –