Android 如何删除PHP echo中返回的XML数据?
我有一个php脚本,它运行在一个响应0或1的服务器上。当我直接在浏览器中执行脚本时,得到0或1。但是,当我通过HttpPost执行同样的操作时,我也会获得关于服务器的XML数据。我相信页面源代码也会在响应中返回。 代码如下:Android 如何删除PHP echo中返回的XML数据?,android,http,Android,Http,我有一个php脚本,它运行在一个响应0或1的服务器上。当我直接在浏览器中执行脚本时,得到0或1。但是,当我通过HttpPost执行同样的操作时,我也会获得关于服务器的XML数据。我相信页面源代码也会在响应中返回。 代码如下: public static String executeHttpPost(String strURL, ArrayList postParameters) throws Exception { BufferedReader brStrReader = nu
public static String executeHttpPost(String strURL, ArrayList postParameters) throws Exception
{
BufferedReader brStrReader = null;
String strResult = "";
try
{
//Get the HTTPClient Instance
HttpClient client = getHttpClient();
//Set the HTTP context to BasicHTTPContext
HttpContext context = new BasicHttpContext();
//Perform a HTTPPost with given URL
HttpPost httppost = new HttpPost(strURL);
//Set the Entity
httppost.setEntity(new UrlEncodedFormEntity(postParameters));
//Get the HTTP response
HttpResponse response = client.execute(httppost, context);
//Get the response into string
strResult = EntityUtils.toString(response.getEntity());
}
catch (java.net.SocketTimeoutException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
//Check if BufferedStreamReader object is null
if (brStrReader != null)
{
try
{
//Close the BufferedStreamReader
brStrReader.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
return strResult;
这是输出:
1<!-- www.serversfree.com Analytics Code --><script src="http://www.serversfree.com"></script><noscript><a title="Free hosting servers" href="http://www.serversfree.com">Free servers</a><a title="Free websites hosting server" href="http://www.serversfree.com">Free websites hosting server</a><a title="Free hosting server features" href="http://www.serversfree.com/server-features/">Free server features</a><a title="Free hosting" href="http://www.bugs3.com">Free hosting</a><a title="Page rank" href="http://www.1pagerank.com">Page rank</a></noscript>
1
请分享您的代码和输出。@SulthanAllaudeen:我已经添加了代码和输出。我正在重用来自另一个应用程序的相同代码。另一个应用程序仅返回0或1。