hy I have to work with a server mobile app. In this app I am hitting to the url which takes the parameters such as user name and password and it returns the server response , it tells that server is up or not , Means yes or no. But it returns in a xml file . So How to save that xml file and then convert it to string . I want to convert it into string so that I can show him that server is up Yes and no. Please any help would be appreciated
this is a code I am using
`public String login(String uname,String password)
{
InputStream is = null;
String result = "";
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
try
{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("Your Url");
nameValuePairs.add(new BasicNameValuePair("emailid", uname));
nameValuePairs.add(new BasicNameValuePair("password", password));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}
catch (Exception e)
{
Log.e("log_tag", "Error in http connection " + e.toString());
}
// convert response to string
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader( is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
is.close();
result = sb.toString();
Log.v("log","Result :"+result);
}
catch (Exception e)
{
Log.v("log", "Error converting result " + e.toString());
}
return result;
}`
but in this it is working for jason And I am getting the xml file ,so how to convert that file that is all y problem