2017-08-04 52 views
0

我有通过的SimpleXML +改造解析XML文件中的问题简单的XML解析器获得空

我从这里得到的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; 
 
    } 
 
}

@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; 
 
}

但是,一旦我得到的效应初探,通道值为空,无论是地震列表

请帮助或指出其中我做错。

非常感谢

回答

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; 
     }