Reputation: 81
Here is my code
try
{
url = new URL("http://localhost/abc//webservice.php?op=login");
connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestMethod("POST");
connection.setRequestProperty("user_email", "[email protected]");
connection.setRequestProperty("user_password", "123456");
request = new OutputStreamWriter(connection.getOutputStream());
request.write(parameters);
request.flush();
request.close();
if(connection.getResponseCode() == HttpURLConnection.HTTP_OK)
{
String line = "";
InputStreamReader isr = new InputStreamReader(connection.getInputStream());
BufferedReader reader = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
while ((line = reader.readLine()) != null)
{
sb.append(line + "\n");
}
response = sb.toString();
isr.close();
reader.close();
This is my response :
<?xml version ='1.0' encoding ='UTF-8' ?>
<root>
<userid>36</userid>
<message>Successfully Loggin in</message>
</root>
Please tell me how can I get value of the tags <userid>
and <message>
Upvotes: 0
Views: 649
Reputation: 43098
Your responce is a simple xml. Parse it with any technology you want:
Upvotes: 5