title: parse Xml data like json parse
body: <p>I am developing android application and I got a error When I parse XML data like Json.I confused how many array has this data? I share code at below. can anyone help me or sharing example code like this xml data?  <img src="https://i.stack.imgur.com/hdh1r.jpg" alt="I added photo of parsing data"></p>
  
  <pre><code>public class MainActivity extends Activity implements OnRefreshListener,
          OnClickListener {
      // Declare Variables
      JSONObject jsonobject;
      JSONArray jsonarray;
      JSONArray jsonarray2;
      ListView listview;
      ListViewAdapter adapter;
      ProgressDialog mProgressDialog;
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; arraylist;
      static String RANK = "rank";
      static String COUNTRY = "country";
      static String POPULATION = "population";
      static String FLAG = "flag";
  
      Button btngeri;
  
      static Integer[] imageId = { R.drawable.enveloppe, R.drawable.enveloppe,
              R.drawable.enveloppe, R.drawable.enveloppe, R.drawable.enveloppe,
              R.drawable.enveloppe, R.drawable.enveloppe };
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          // Get the view from listview_main.xml
          setContentView(R.layout.listview_main);
  
          btngeri = (Button) findViewById(R.id.btn_geri);
          btngeri.setOnClickListener(this);
  
  
          // Execute DownloadJSON AsyncTask
          new DownloadJSON().execute();
      }
  
      // DownloadJSON AsyncTask
      private class DownloadJSON extends AsyncTask&lt;Void, Void, Void&gt; {
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              // Create a progressdialog
              mProgressDialog = new ProgressDialog(MainActivity.this);
              // Set progressdialog title
              mProgressDialog.setTitle("Mail Kutusu");
              // Set progressdialog message
              mProgressDialog.setMessage("Güncelleme Yapılıyor...");
              mProgressDialog.setIndeterminate(false);
              // Show progressdialog
              mProgressDialog.show();
          }
  
          @Override
          protected Void doInBackground(Void... params) {
              // Create an array
              arraylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
              // Retrieve JSON Objects from the given URL address
              jsonobject = JSONfunctions
                      .getJSONfromURL("http://78.186.62.169:8210/AnketServis.asmx/Message");
  
              try {
                  // Locate the array name in JSON
  
                  jsonarray = jsonobject.getJSONArray("MessageVO");
  
                  for (int i = 0; i &lt; jsonarray.length(); i++) {
                      HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
                      jsonobject = jsonarray.getJSONObject(i);
                      // Retrive JSON Objects
                      // map.put("rank", jsonobject.getString("rank"));
                      map.put("country", jsonobject.getString("Konu"));
                      // map.put("population",
                      // jsonobject.getString("population"));
                      // map.put("flag", jsonobject.getString("flag"));
                      // Set the JSON Objects into the array
                      arraylist.add(map);
                  }
              } catch (JSONException e) {
                  Log.e("Error", e.getMessage());
                  e.printStackTrace();
              }
              return null;
          }
  
          @Override
          protected void onPostExecute(Void args) {
              // Locate the listview in listview_main.xml
              listview = (ListView) findViewById(R.id.listview);
              // Pass the results into ListViewAdapter.java
              adapter = new ListViewAdapter(MainActivity.this, arraylist, imageId);
              // Set the adapter to the ListView
              listview.setAdapter(adapter);
              // Close the progressdialog
              mProgressDialog.dismiss();
          }
      }
  </code></pre>