我将尝试解析一个类似于这样的BART车站列表: https://api.bart.gov/docs/stn/stns.aspx,使用Simple XML(链接:http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php)。我已经设置了如下的反序列化对象:
站点对象:
无论我尝试什么,都无法成功解析站点列表。我做错了什么?
StationList object:
@Root(name = "root")
public class StationList {
@ElementList(name = "stations", inline = true)
private List<Station> stations;
@Element(name = "message", required = false)
private String message;
public StationList() {
}
public List<Station> getStations() {
return stations;
}
public String getMessage() {
return message;
}
}
站点对象:
@Root(name = "station", strict = false)
public class Station {
@Element(name ="name")
private String name;
@Element(name = "abbr")
private String abbr;
@Element(name = "gtfs_latitude")
private double latitude;
@Element(name = "gtfs_longitude")
private double longitude;
@Element(name = "address")
private String address;
@Element(name = "city")
private String city;
@Element(name = "county")
private String county;
@Element(name = "state")
private String state;
@Element(name = "zipcode")
private int zipCode;
public String getName() {
return name;
}
public String getAbbr() {
return abbr;
}
public double getLatitude() {
return latitude;
}
public double getLongitude() {
return longitude;
}
public String getAddress() {
return address;
}
public String getCounty() {
return county;
}
public String getState() {
return state;
}
public int getZipCode() {
return zipCode;
}
}
无论我尝试什么,都无法成功解析站点列表。我做错了什么?