嗨,我有一个像这样的网络服务
<audio title="Terry Waychuk Pure2010" audio="http://www.boodang.com/api/audio/**Terry_Waychuk**/Terry_Waychuk_Pure2010.mp3" description="Terry Waychuk Pure2010" createddate = "23-01-2011" thumbnail="http://www.boodang.com/api/thumb/boodean_logo.png" />
<audio title="Terry Waychuk frequency2010" audio="http://www.boodang.com/api/audio/**Terry_Waychuk**/Terry_Waychuk_frequency2010.mp3" description="Terry Waychuk frequency2010" createddate = "23-01-2011" thumbnail="http://www.boodang.com/api/thumb/boodean_logo.png" />
<audio title="The Grimey Tech RandomHero FlooRLayer Scooty OH Mazik Boodang 10 Year Anniversary Promo Mix" audio="http://www.boodang.com/api/audio/**The_Grimey_Tech**/The_Grimey_Tech_RandomHero_FlooRLayer_Scooty_OH_Mazik_Boodang_10_Year_Anniversary_Promo_Mix.mp3" description="The Grimey Tech RandomHero FlooRLayer Scooty OH Mazik Boodang 10 Year Anniversary Promo Mix" createddate = "23-01-2011" thumbnail="http://www.boodang.com/api/thumb/boodean_logo.png" />
<audio title="The Grimey Tech and Titus 1 Warper Warfare" audio="http://www.boodang.com/api/audio/**The_Grimey_Tech**/The_Grimey_Tech_and_Titus_1_Warper_Warfare.mp3" description="The Grimey Tech and Titus 1 Warper Warfare" createddate = "23-01-2011" thumbnail="http://www.boodang.com/api/thumb/boodean_logo.png" />
.
.
.
.
.第一个属性有一个文件名相同的mp3文件。用*表示的文件名和接下来的两个文件在同一个文件name.so中也有一个mp3文件,我想根据文件names.first显示一个列表视图,我想像这样显示一个列表视图
Terry_Waychuk
The_Grimey_Tech单击其中任何一个文件,然后以mp3文件标题显示列表视图( Terry_Waychuk中前两个文件标题,The_Grimey_Tech中的下两个文件标题)。所以请告诉我如何在属性值中获取特定的名称,以及如何将特定的mp3文件添加到该文件夹(Terry_Waychuk或The_Grimey_Tech)。
发布于 2011-01-28 18:42:02
使用android XmlPullParser的一种方法(您没有指定您使用的是哪一个)是在接收XmlPullParser.START_TAG时将属性拉入Map<String, String>,因此,假设主解析::
private void parseContent(XmlPullParser parser)
throws XmlPullParserException,IOException,Exception {
int eventType;
while((eventType=parser.next()) != XmlPullParser.END_TAG) {
if (eventType == XmlPullParser.START_TAG) {
Log.d(MY_DEBUG_TAG,"Parsing Attributes for ["+parser.getName()+"]");
Map<String,String> attributes = getAttributes(parser);
}
else if(eventType==...);
else {
throw new Exception("Invalid tag at content parse");
}
}
}
private Map<String,String> getAttributes(XmlPullParser parser) throws Exception {
Map<String,String> attrs=null;
int acount=parser.getAttributeCount();
if(acount != -1) {
Log.d(MY_DEBUG_TAG,"Attributes for ["+parser.getName()+"]");
attrs = new HashMap<String,String>(acount);
for(int x=0;x<acount;x++) {
Log.d(MY_DEBUG_TAG,"\t["+parser.getAttributeName(x)+"]=" +
"["+parser.getAttributeValue(x)+"]");
attrs.put(parser.getAttributeName(x), parser.getAttributeValue(x));
}
}
else {
throw new Exception("Required entity attributes missing");
}
return attrs;
}parser.getName()返回与XmlPullParser.START_TAG关联的实体的名称。
希望这能有所帮助
https://stackoverflow.com/questions/4827168
复制相似问题