从xml解析得到的数据放入一个List<util> utils的数组对象中,util中有{ id time video} 三个属性,id是节点。但是现在我不知道xml中有多少个{ id time video } 的数据,并且所有的数据都要使用到。请问我改怎么去取出List<util> utils里面的所有的数据?????
搞一个内部类: static public class DATA { int id; String time; String video; } 从xml读出来后,全部的放在这个ArrayList<DATA> list中,。 然后。 Iterator it = ArrayList.interator(); while(it.hasNext) { DATA temp = it.next(); //下面就可以读你要的数据了啊
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
"
}
解析出来的全部的往List<util> utils.放。utils.put()..
后面的操作就是iterator, 和List的基本操作了
id:"3" time:"8:20" video:"22.mp4"
id:"4" time:"9:20" video:"43.3gp"
像这样的List<util> utils的数组对象 其中的id还可能会更加的多,也是不确定的顺序。但是要得到time 和video。改怎么去取出来?
static public class DATA {
int id;
String time;
String video;
}
从xml读出来后,全部的放在这个ArrayList<DATA> list中,。
然后。
Iterator it = ArrayList.interator();
while(it.hasNext) {
DATA temp = it.next();
//下面就可以读你要的数据了啊
这个是我得到的数据:就是说7:10到7:20播放 15.MP4这个视频,而8:10到8:20播放1229730718.wmv这个视频。现在我的问题是该怎么样分别的取出那两个视频和播放视频的时间。。???而你的方法是把他们分别用对象的形式取出来如Util [id=12, hours=7, minutes=10, end_hours=7, end_minutes=20, vid=-1, videos=15.mp4, name=null]……
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
&& (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
"
}
这样的代码,然后里面就是读取name,属性了。具体的属性的定义id, hours.....直接去解析就是了,
不知道你的xml格式是什么,但是android 解析代码,在android的源代码里面到处都是,比如解析layout等。建议你去看看吧