这是我的代码
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", "abc@abc.com");
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();
这是我的回答:
<?xml version ='1.0' encoding ='UTF-8' ?>
<root>
<userid>36</userid>
<message>Successfully Loggin in</message>
</root>
请告诉我如何获得代码<userid>
和<message>