急!我如何在android手机端解析webservice返回的dataset数据啊?急用。在线等待。有用功的吗
------解决方案--------------------
SoapObject so=(SoapObject)rpc.getProperty(1);
System.out.println("username:"+getReturnValueByFieldName(so,"f_username"));
String st=getReturnValueByFieldName(so,"f_username");
if(st!=null){
Toast.makeText(MoveActivity.this, st,Toast.LENGTH_LONG).show();
Intent intent=new Intent();
// intent.putExtra("name", st);
intent.setClass(MoveActivity.this, MoveSy.class);
MoveActivity.this.startActivity(intent);
}
public static String getReturnValueByFieldName(SoapObject so,String keytobefind)
{
String returnValue="";
HashMap<String, String> keyIndexMapping =new HashMap();
keyIndexMapping.put("id","0");
keyIndexMapping.put("f_username","1");
int indexInReturn=Integer.parseInt(""+keyIndexMapping.get(keytobefind));
returnValue=so.getProperty(indexInReturn).toString();
return returnValue;
}
------解决方案--------------------
if (envelope.getResponse() != null) {
SoapObject soapObject = (SoapObject) envelope.bodyIn;
for (int i = 0; i < soapObject.getPropertyCount(); i++) {
SoapObject soap1 = (SoapObject) soapObject.getProperty(i);
for (int j = 0; j < soap1.getPropertyCount(); j++) {
System.out.println(soap1.getProperty(j).toString())
}
}
}
根据xml 的格式,多遍历几次就出来了