I am writing an application. From the server the answer comes in XML:

<words> <word begin="930" end="1410">корабли</word> <word begin="1410" end="2100">лавировали</word> <word begin="2100" end="2730">лавировали</word> <word begin="2730" end="2970">да</word> <word begin="2970" end="3690">невылавировали</word> </words> 

I get it using Retrofit. I convert using SimpleXmlConverterFactory for this article . Can not deserialize it. I use this source here . I can not find the structure for the class. This option is not suitable:

 @Root(name = "words") public class Words { @ElementArray public String[] word; } 

This one also does not fit

 @Root(name = "words") public class Words { @ElementList public List<String> word; } 

    2 answers 2

      @Root(name = "words") public class Words { @ElementList private List<Word> words; // getter/setter } @Root(name = "word") public class Word { @Element private int begin; @Element private int end; @Element private String say; // getters/setters } 

    I understand that something like this should be

      The correct answer is this one, if anyone is interested in @Root (name = "words") public static class Words {

        @ElementList(inline = true) public List<Word> word; } @Root(name = "word") public static class Word { @Attribute(name = "begin") private String begin; @Attribute(name = "end") private String end; @Text String value; } 

      It helped