开发者

Android: Parsing webservices response and store in a local variable

开发者 https://www.devze.com 2023-03-16 15:02 出处:网络
In myweb services program I am getting the response as a string value to the logcat. the value is 1 if its success and 0 if its failure and -1 if field is empty.

In my web services program I am getting the response as a string value to the logcat. the value is 1 if its success and 0 if its failure and -1 if field is empty.

I want to Parse my response answer(0 ,1) to store in a local variable and I want to show the alert like

 if(result==1)
                 {
           show the alert"Registered"
}

else if(result==0){
    show alert"Try Again"
}

else if(result == -1)
{
show alert "Field is empty"
}

How ever showing the alert is easy, but as I am new to web services, I don't know how to parse the result and store in a local variable. someone please help me to solve this

Help is always appreciated....!

         request.addProperty("email", email)开发者_如何转开发;
        request.addProperty("contact", contact);
        request.addProperty("fname", fname);
        request.addProperty("lname", lname);
        request.addProperty("gender", gender);
        request.addProperty("dateofbirth", dob);
        request.addProperty("password", password);
        request.addProperty("latitude", "76");
        request.addProperty("longitude", "82");
        request.addProperty("device_id", "12345"); 

            aht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); 
            aht.call(SOAP_ACTION, soapEnvelope);

            SoapObject resultsRequestSOAP = (SoapObject) soapEnvelope.bodyIn;
            Log.v("TAG", String.valueOf(resultsRequestSOAP));


You can use Sax parsing,Dom parsing or other two parsing method if you have simple xml file in the web.If you work with complex web page then you can use Jsoup.here i told how to use jsoup to parse any kind of data from any pages

here is the link of how you can use SAX/DOM for simple XML file parsing

0

精彩评论

暂无评论...
验证码 换一张
取 消