I am creating an application where I have to post to this url: Url to get KML
The url is supposed to return a KML file, according to this tutorial:
But when I am hitting the url, I am getting a HTML file as a response which is very difficult to parse and is useless.
My source code is:
//Calling function to get the response KML
getKmlFromUrl("https://maps.google.com/maps?saddr=22.583375060000,88.434077990000&daddr=22.491368100000,88.348189300000&ie=UTF8&0&om=0&output=kml");
//This is the function to get the KML file and show it in logcat void getKmlFromUrl(String urlString) { String kml = null;
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
makeAToast("URL:"+urlString);
HttpPost httpPost = new HttpPost(urlString);
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
kml = EntityUtils.toString(httpEntity);
System.out.println("KML: "+kml);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// // return XML
// // return xml;
}
After doing all these, I am not getting a KML response, instead I am getting an HTML response. The response (in logcat) is over here:
Where am I going wrong?