title: Android JSOUP Parsing Tables fromWeb Sites
body: <p>I am having an issue with parsing the following website:</p>
  
  <p><a href="http://www.x-rates.com/d/USD/table.html" rel="nofollow noreferrer">http://www.x-rates.com/d/USD/table.html</a></p>
  
  <p>I am very, very very new to android programming and I am thinking about creating a currency converter, now I know that there is a bunch out there however, I am trying to fast track my programming initiation and get myself immersed in code.</p>
  
  <p>I found a tutorial that tried to explain and it was helpful for a website with the need for a specific item. the code is below:</p>
  
  <pre><code>package com.ve.webgrab;
  
  import java.io.IOException;
  import java.util.ArrayList;
  import android.app.ListActivity;
  import android.os.Bundle;
  import org.jsoup.Jsoup;
  import org.jsoup.nodes.Document;
  import org.jsoup.nodes.Element;
  import org.jsoup.select.Elements;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  import android.widget.Toast;
  import android.view.View;
  
  public class WebgrabActivity extends ListActivity {
  
  public void onCreate(Bundle icicle) {
          super.onCreate(icicle);
  
  ArrayList&lt;String&gt; tableRowStrings = new ArrayList&lt;String&gt;();
  
  Document doc = null;
          try {
              doc = Jsoup.connect("http://www.x-rates.com/d/USD/table.html").get();
          } 
          catch (IOException e) {
              e.printStackTrace();
          }
  
         String testString  = "American";
          Elements tableRows = doc.select("tr");
          for (Element tableRow : tableRows){
               if (tableRow.hasText()){
                      String rowData = tableRow.text();
                      if(rowData.contains(testString)){
                              tableRowStrings.add(rowData);
                  }
            }
      } 
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, tableRowStrings);
          setListAdapter(adapter);
    }
  
  @Override
      protected void onListItemClick(ListView l, View v, int position, long id) {
          String item = (String) getListAdapter().getItem(position);
          Toast.makeText(this, item + " selected", Toast.LENGTH_LONG).show();
      }
  }
  </code></pre>
  
  <p>I need to be able to get the table with the usd to other currency so that I can have it in a database and then use it for the conversion. I believe the section that I need to look at is:</p>
  
  <pre><code>       String testString  = "American";
          Elements tableRows = doc.select("tr");
          for (Element tableRow : tableRows){
               if (tableRow.hasText()){
                      String rowData = tableRow.text();
                      if(rowData.contains(testString)){
                              tableRowStrings.add(rowData);
                  }
            }
      } 
  </code></pre>
  
  <p>What I need to accomplish:</p>
  
  <ul>
  <li><p>Get the website:- - I believe this is accomplished:-</p>
  
  <pre><code>        doc = Jsoup.connect("http://www.x-rates.com/d/USD/table.html").get();
  </code></pre></li>
  <li><p>Select the table on the website with particular interest on the Conversion rate: - Still cannot figure this part out.</p></li>
  <li><p>Test for the Table to ensure it is the correct one:</p>
  
  <pre><code>   String testString  = "American";
  
                  if(rowData.contains(testString)){
  </code></pre></li>
  <li><p>Take the data on the table and display to a list view just to ensure that the correct data is being gathered:</p>
  
  <pre><code>    ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, tableRowStrings);
      setListAdapter(adapter);
  </code></pre></li>
  <li><p>Break up the table <code>&lt;td&gt;</code> into country and conversion rate and then place it into a database.</p></li>
  </ul>
  
  <p>I am looking for guidance, please remember that I am totally new to this and I want to build out this app for a learning experience and a spring board to bigger and better apps, example code is definitely welcome, I would appreciate all the help  I can get.</p>