@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView tv = (TextView) findViewById(R.id.tv);
List<WeatherBean> list = ParseXml.parse(MainActivity.class.getClassLoader().getResourceAsStream("test.xml"));
StringBuffer sb = new StringBuffer();
for(WeatherBean bean : list){
String str = bean.toString();
sb.append(str);
sb.append("\n");
}
tv.setText(sb.toString());
}
}
这样看来,解析xml文件还是非常简单的。