我正在尝试从此 URL 获取简单的 HTTP 响应:http ://realtorsipad.demowebsiteonline.net/eventsfeed.php
但令人惊讶的是,它没有返回预期的 XML 响应,而是返回另一个 HTML 页面!
我无法理解什么是问题。
这是示例活动:
public class MainActivity1 extends Activity {
String parsingWebURL = "http://realtorsipad.demowebsiteonline.net/eventsfeed.php";
String line = "";
Document docXML;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
line = getXML();
System.out.println(line);
}
// ------------------------------------------------
public String getXML() {
String strXML = "";
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(parsingWebURL);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
strXML = EntityUtils.toString(httpEntity);
return strXML;
} catch (Exception e1) {
e1.printStackTrace();
}
return strXML;
}
}