Search code examples
androidweb-servicesksoap2

how to get the values from soap response in android?


the following xml tag for webservice response ,i dont know how to parse it..help me..

<NewDataSet>
            <JOBLIST>
            <CSIDNO>CS13224</CSIDNO>
            <PName>Selva</PName>
            <HouseID>G 34</HouseID>
            <NAME>Dilipan</NAME>
            <Address>Coimbatore</Address>
            </JOBLIST>
            <JOBLIST>
            <CSIDNO>CS13224</CSIDNO>
            <PName>Selva</PName>
            <HouseID>G 35</HouseID>
            <NAME>Kanrupannan</NAME>
            <Address>Coimbatore</Address>
            </JOBLIST>
            </NewDataSet>

i am using the following java code .....

for(int i=0;i<result.getPropertyCount();i++)
        {
            SoapObject ob=(SoapObject)result.getProperty(i);
            homeid[i]=String.valueOf(ob.getProperty("HouseID"));
            namearr[i]=String.valueOf(ob.getProperty("NAME"));
            address[i]=String.valueOf(ob.getProperty("Address"));
            csidno[i]=String.valueOf(ob.getProperty("CSIDNO"));


        }

how to get the values form xml tag..


Solution

  • Its pretty simple you have to get the respose as a string and use pattern matches to extract the detail you needed>Please see this post hope it helps you and you understand it.

    String r = NameArray.columncount("userid", limitstart, loadNumber,loggername);
    String temp = r.replaceAll(";\\s", ",").replaceAll("string=", " ")
    .replace("anyType{", "").replace(",}", "");
    enter code here
    

    check this link for step by step instruction http://amalan008.blog.com/2013/02/07/how-to-process-an-array-returned-by-a-wsdl-android/