I am trying to return a string from my php file to my android application. The php file is not in json form. jsonobject just returns error 07-28 20:10:56.538: W/System.err(2936): org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject I have also tried SAXParser, but i understand that that is for xml files only. When I use a StringBuilder like such
public static String iStream_to_String(InputStream is1) {
BufferedReader rd = new BufferedReader(new InputStreamReader(is1), 8192);
String line;
StringBuilder sb = new StringBuilder();
String longitudecord = "";
try {
while ((line = rd.readLine()) != null) {
sb.append(line+"\n");
}
// rd.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String contentOfMyInputStream = sb.toString();
return contentOfMyInputStream;
}
I get a response much like this one <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> the response That I want to get is a simple string returning a given error file. is there any possible way to do such a simple task without json?
also i want to add the file type of the php is application/x-httpd-php if that helps or not.
I was just calling the php wrong:/