日期:2014-05-20 浏览次数:20841 次
xml文件
<QueryRegionByDeviceIdResp>
<resultCode>0</resultCode>
<RegionList>
<Region>
<regionId>340000</regionId>
<regionName>安徽省</regionName>
<regionLevel></regionLevel>
<parentId></parentId>
</Region>
<Region>
<regionId>110000</regionId>
<regionName>北京市</regionName>
<regionLevel></regionLevel>
<parentId></parentId>
</Region>
</RegionList>
</QueryRegionByDeviceIdResp>
三个class类如下
public class QueryRegionByDeviceIdResp {
private String resultCode;
// private List<Region> regionList = new ArrayList<Region>();
private RegionList regionList;
public String getResultCode() {
return resultCode;
}
public void setResultCode(String resultCode) {
this.resultCode = resultCode;
}
public RegionList getRegionList() {
return regionList;
}
public void setRegionList(RegionList regionList) {
this.regionList = regionList;
}
}
public class RegionList {
private List<Region> regionList;
public List<Region> getRegionList() {
return regionList;
}
public void setRegionList(List<Region> regionList) {
this.regionList = regionList;
}
}
public class Region {
private String regionId;
private String regionName;
private String regionLevel;
private String parentId;
public String getRegionId() {
return regionId;
}
public void setRegionId(String regionId) {
this.regionId = regionId;
}
public String getRegionName() {
return regionName;
}
public void setRegionName(String regionName) {
this.regionName = regionName;
}
public String getRegionLevel() {
return regionLevel;
}
public void setRegionLevel(String regionLevel) {
this.regionLevel = regionLevel;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
}
XStream xstream = new XStream();
xstream.alias(
"QueryRegionByDeviceIdResp",
com.XXX.entity.response.QueryRegionByDeviceIdResp.class);
xstream.alias("RegionList", com.XXX.entity.found.RegionList.class);
xstream.alias("Region", com.XXX.entity.found.Region.class);
QueryRegionByDeviceIdResp queryRegionByDeviceIdResp = new QueryRegionByDeviceIdResp();