Parsing SoapObject Responst in android

北慕城南 提交于 2019-11-28 13:11:06

Basicly it's something like this:

SoapObject GetListResponse = (SoapObject)result.getProperty(0); 
SoapObject DocumentElement = (SoapObject)GetListResponse.getProperty(3);
SoapObject Table1 = (SoapObject)DocumentElement.getProperty(0);

This contains SoapObjects within SoapObjects, so the best thing to do is to write a recursive method to scan through all properties and find the information you need. Something like this:

private static void ScanSoapObject(SoapObject result) 
{
    for(int i=0;i<result.getPropertyCount();i++)
    {
        if(result.getProperty(i) instanceof SoapObject)
        {               
             ScanSoapObject((SoapObject)result.getProperty(i));
        }
        else
        {               
            //do something with the current property

            //get the current property name:
            PropertyInfo pi = new PropertyInfo();
            result.getPropertyInfo(i,pi);
            String name = pi.getName();
        }
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!