2017-08-04 11 views
0

私はシンプルなXMLパーサは、

は私が http://www.gdacs.org/xml/rss_eq_48h_low.xml

レスポンスクラス

@Root(name = "rss", strict = false) 
 
public class EarthQuakeResponse { 
 
    @Root(name = "channel", strict = false) 
 
    public Channel channel; 
 

 
    public class Channel { 
 
     @ElementList 
 
     public List<EarthQuake> earthquakes; 
 
    } 
 
}

レトロフィットにより、ここからxmlファイルを取得するのSimpleXML +レトロフィットにより、XMLファイルの解析に問題があり、ヌル取得します

@Element(name = "item") 
 
public class EarthQuake { 
 
    @Element(name = "title") 
 
    public String title; 
 

 
    @Element(name = "description") 
 
    public String description; 
 

 
    @Element(name = "pubDate") 
 
    public String pubDate; 
 

 
    @Element(name = "georss:point") 
 
    public String point; 
 
}

しかし、私はREPONSEを得れば、チャネル値がnullの場合、どちらの地震一覧

私が間違っていませんでした助けたり、指摘してください。

答えて

0

たくさん

おかげで、これを試してみてください:

@Root(name = "rss", strict = false) 
    public class EarthQuakeResponse { 
     @Element(name = "channel") 
     public Channel channel; 

    } 
    @Root(name = "channel", strict = false) 
    public class Channel { 
      @ElementList 
      public List<EarthQuake> earthquakes; 
     } 
関連する問題