title: Error parsing JSON Array, DOCTYPE
body: <p>ive got a working listview which receives JSON from my DB. But when i try with this link:  I get "Error parsing data org.json.JSONException: Value 
  
  <p>The JSON output is clean and should work! My activitiy</p>
  
  <pre><code>package com.spxc.ssa.streaming;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  
  import com.actionbarsherlock.app.SherlockListActivity;
  import com.actionbarsherlock.view.MenuItem;
  import com.spxc.ssa.streaming.task.JsonAsync;
  import com.spxc.ssa.streaming.task.JsonAsync.JsonListener;
  
  public class ListShowsController extends SherlockListActivity implements
          OnClickListener {
  
      private ProgressDialog mDialog;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          // getWindow().setFormat(PixelFormat.TRANSLUCENT);
          setContentView(R.layout.dblist);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
          getSupportActionBar().setTitle("Shows");
  
          JsonAsync asyncTask = new JsonAsync();
          // Using an anonymous interface to listen for objects when task
          // completes.
          asyncTask.setJsonListener(new JsonListener() {
              @Override
              public void onObjectReturn(JSONObject object) {
                  handleJsonObject(object);
              }
          });
          // Show progress loader while accessing network, and start async task.
          mDialog = ProgressDialog.show(this, getSupportActionBar().getTitle(),
                  getString(R.string.loading), true);
          asyncTask.execute("");
  
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
          case android.R.id.home:
              finish();
              break;
          }
          return false;
      }
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
  
      }
  
      private void handleJsonObject(JSONObject object) {
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
          try {
  
              JSONArray shows = object.getJSONArray("items");
  
              for (int i = 0; i &lt; shows.length(); i++) {
                  HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                  JSONObject e = shows.getJSONObject(i);
  
                  map.put("video_id", String.valueOf(i));
                  map.put("video_title", "" + e.getString("video_title"));
                  //map.put("season", "Season: " + e.getString("season"));
                  map.put("video_location", "" + e.getString("video_location"));
                  mylist.add(map);
              }
          } catch (JSONException e) {
              Log.e("log_tag", "Error parsing data " + e.toString());
          }
  
          ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.dbitems,
                  new String[] { "video_title", "video_location" }, new int[] { R.id.item_title,
                          R.id.item_subtitle });
  
          setListAdapter(adapter);
  
          final ListView lv = getListView();
          lv.setTextFilterEnabled(true);
          lv.setOnItemClickListener(new OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                      int position, long id) {
                  @SuppressWarnings("unchecked")
                  HashMap&lt;String, String&gt; o = (HashMap&lt;String, String&gt;) lv
                          .getItemAtPosition(position);
  
                  Intent myIntent = new Intent(ListShowsController.this,
                          ShowsController.class);
                  myIntent.putExtra("video_title", o.get("video_title"));
                  //myIntent.putExtra("season", o.get("season"));
                  myIntent.putExtra("video_location", o.get("video_location"));
                  startActivity(myIntent);
              }
          });
  
          if (mDialog != null &amp;&amp; mDialog.isShowing()) {
              mDialog.dismiss();
          }
      }
  
  }
  </code></pre>
  
  <p>AsyncTask</p>
  
  <pre><code>package com.spxc.ssa.streaming.task;
  
  import org.json.JSONObject;
  
  import android.os.AsyncTask;
  import android.util.Log;
  
  public class JsonAsync extends AsyncTask&lt;String, Void, JSONObject&gt; {
  
      public interface JsonListener {
          public void onObjectReturn(JSONObject object);
      }
  
      public void setJsonListener(JsonListener jsonListener) {
          mListener = jsonListener;
      }
  
      private JsonListener mListener;
      public static final String TAG = JsonAsync.class.getSimpleName();
  
      @Override
      protected JSONObject doInBackground(String... params) {
          // The argument passed into tasks are arrays. So you can pass 0 or more
          // arguments, when calling from activity, it's really up to you. They
          // just have to be separated by commas. Like this :
          // new JsonAsync.execute("thisUrl", "thatUrl", "anotherUrl");
          // Although I am only grabbing the first item in the array, by calling
          // params[0] below.
  
          JSONObject object = null;
  
          if (params != null &amp;&amp; params.length &gt; 0) {
              object = JSONfunctions.getJSONfromURL(params[0]);
          } else {
              Log.e(TAG, "Task needs an argument to be able to retrieve data.");
          }
  
          // I return the item out of this method, because it is happening of the
          // UI thread, so it can;t update items on the screen. You can work with
          // a database from this method. That is actually recommended.
          return object;
      }
  
      @Override
      protected void onPostExecute(JSONObject result) {
          // This method can touch UI components without throwing an error.
          if (result != null &amp;&amp; mListener != null) {
              mListener.onObjectReturn(result);
          }
          super.onPostExecute(result);
      }
  }
  </code></pre>
  
  <p>I've never seen this error before! What is the problem? </p>
  
  <p>Any help is much appreciated ! Thanks</p>
  
  <p>EDIT:
  My other activity which works:</p>
  
  <pre><code>package com.spxc.ssa.streaming;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  
  import com.actionbarsherlock.app.SherlockListActivity;
  import com.actionbarsherlock.view.MenuItem;
  import com.spxc.ssa.streaming.task.JsonAsync;
  import com.spxc.ssa.streaming.task.JsonAsync.JsonListener;
  
  public class ListMoviesController extends SherlockListActivity implements
          OnClickListener {
  
      private ProgressDialog mDialog;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          // getWindow().setFormat(PixelFormat.TRANSLUCENT);
          setContentView(R.layout.dblist);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
          getSupportActionBar().setTitle("Movies");
  
          JsonAsync asyncTask = new JsonAsync();
          // Using an anonymous interface to listen for objects when task
          // completes.
          asyncTask.setJsonListener(new JsonListener() {
              @Override
              public void onObjectReturn(JSONObject object) {
                  handleJsonObject(object);
              }
          });
          // Show progress loader while accessing network, and start async task.
          mDialog = ProgressDialog.show(this, getSupportActionBar().getTitle(),
                  getString(R.string.loading), true);
          asyncTask.execute("http://strongpixel.com/java/movies.php");
  
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
          case android.R.id.home:
              finish();
              break;
          }
          return false;
      }
  
      @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
  
      }
  
      private void handleJsonObject(JSONObject object) {
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
  
          try {
  
              JSONArray shows = object.getJSONArray("items");
  
              for (int i = 0; i &lt; shows.length(); i++) {
                  HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                  JSONObject e = shows.getJSONObject(i);
  
                  map.put("id", String.valueOf(i));
                  map.put("name", "" + e.getString("name"));
                  //map.put("date", "Released: " + e.getString("date"));
                  map.put("path", "" + e.getString("path"));
                  mylist.add(map);
              }
          } catch (JSONException e) {
              Log.e("log_tag", "Error parsing data " + e.toString());
          }
  
          ListAdapter adapter = new SimpleAdapter(this, mylist, R.layout.dbitems,
                  new String[] { "name", "path" }, new int[] { R.id.item_title,
                          R.id.item_subtitle });
  
          setListAdapter(adapter);
  
          final ListView lv = getListView();
          lv.setTextFilterEnabled(true);
          lv.setOnItemClickListener(new OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                      int position, long id) {
                  @SuppressWarnings("unchecked")
                  HashMap&lt;String, String&gt; o = (HashMap&lt;String, String&gt;) lv
                          .getItemAtPosition(position);
  
                  Intent myIntent = new Intent(ListMoviesController.this,
                          MoviesController.class);
                  myIntent.putExtra("name", o.get("name"));
                  myIntent.putExtra("season", o.get("season"));
                  myIntent.putExtra("path", o.get("path"));
                  startActivity(myIntent);
              }
          });
  
          if (mDialog != null &amp;&amp; mDialog.isShowing()) {
              mDialog.dismiss();
          }
      }
  
  }
  </code></pre>
  
  <p>Logcat:</p>
  
  <pre><code>03-12 08:35:18.722: E/log_tag(25208): Error parsing data org.json.JSONException: Value &lt;!DOCTYPE of type java.lang.String cannot be converted to JSONObject
  03-12 09:06:52.877: V/CustomViewAbove(26397): Received ACTION_DOWN
  03-12 09:06:52.920: V/CustomViewAbove(26397): onInterceptTouch moved to:(30.26232, 662.0), diff:(29.26232, 1.0), mLastMotionX:1.0
  03-12 09:06:52.936: V/CustomViewAbove(26397): onInterceptTouch moved to:(73.95948, 663.08905), diff:(72.95948, 0.08905029), mLastMotionX:1.0
  03-12 09:06:52.940: V/CustomViewAbove(26397): this slide allowed true dx: 72.95948
  03-12 09:06:52.940: V/CustomViewAbove(26397): Starting drag! from onInterceptTouch
  03-12 09:06:52.993: V/SlidingMenu(26397): changing layerType. hardware? true
  03-12 09:06:53.229: V/SlidingMenu(26397): changing layerType. hardware? false
  03-12 09:06:54.214: V/CustomViewAbove(26397): Received ACTION_DOWN
  03-12 09:06:54.450: D/dalvikvm(26397): GC_CONCURRENT freed 73K, 7% free 4495K/4812K, paused 3ms+6ms, total 24ms
  03-12 09:06:55.025: E/log_tag(26397): Error parsing data org.json.JSONException: Value &lt;!DOCTYPE of type java.lang.String cannot be converted to JSONObject
  </code></pre>
  
  <p>Edit: 
  I tried the same JSON, but just in a txt file strongpixel.com/java/JSON.txt, this works without any problem, it takes some time to load, but it works.</p>