title: Parse info from slightly different html bodys
body: <p>I am building an email scraper in JAVA which need to scrape information from specific mails. Those mails have been send through a couple of years. I am facing the problem that every year there is a little change in the html code my code works fine for a specific year but won't for the following or previous year. I am looking for a way to write smart code. NEEDED is the value I need, and VARIABLE can be different. SAME TITLE is always the same. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;span class="confirmationtitle"&gt;SAME TITLE 1&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span class="confirmationleft"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span class="confirmationright"&gt;NEEDED1 &lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span class="confirmationleft"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span class="confirmationright"&gt;NEEDED2&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span class="confirmationleft"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span class="confirmationright"&gt;NEEDED3&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span class="confirmationleft"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span class="confirmationright"&gt;NEEDED4&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span class="confirmationleft"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span class="confirmationright"&gt;NEEDED5&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span class="confirmationleft"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span class="confirmationright"&gt;NEEDED6&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Above the code from year x, below from year y. There are multiple table rows like this with different info.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;tr&gt;
     &lt;div style="font-weight: bold; display: block; margin-top: 20px;"&gt;SAME TITLE 1&lt;/div&gt;
     &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span style="width: 145px; display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; vertical-align: top;"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span style="display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; width: 488px; vertical-align: top;"&gt;NEEDED1 &lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span style="width: 145px; display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; vertical-align: top;"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span style="display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; width: 488px; vertical-align: top;"&gt;NEEDED2&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span style="width: 145px; display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; vertical-align: top;"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span style="display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; width: 488px; vertical-align: top;"&gt;NEEDED3&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span style="width: 145px; display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; vertical-align: top;"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span style="display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; width: 488px; vertical-align: top;"&gt;NEEDED4&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span style="width: 145px; display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; vertical-align: top;"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span style="display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; width: 488px; vertical-align: top;"&gt;NEEDED5&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
     &lt;td&gt;&lt;span style="width: 145px; display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; vertical-align: top;"&gt;VARIABLE&lt;/span&gt;&lt;/td&gt;
     &lt;td&gt;&lt;span style="display: inline-block; zoom:1; /* IE 7 Hack starts here*/ *display:inline; line-height: 18px; width: 488px; vertical-align: top;"&gt;NEEDED6&lt;/span&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My code for this specific row in the table: </p>
  
  <pre><code>        String[] SpecificInfo = new String[6];
  
          String TravellerInfoGender = SpecificInfo[0] = headerInfo.split("&lt;/span&gt;&lt;/td&gt;")[1].split("&lt;/span&gt;")[0].split("&gt;")[2];
          String TravellerInfoFirstname = SpecificInfo[1] = headerInfo.split("&lt;/span&gt;&lt;/td&gt;")[3].split("&lt;/span&gt;")[0].split("&gt;")[2];
          String TravellerInfoMiddleName = SpecificInfo[2] = headerInfo.split("&lt;/span&gt;&lt;/td&gt;")[5].split("&lt;/span&gt;")[0].split("&gt;")[2];
          String TravellerInfoSurName = SpecificInfo[3] = headerInfo.split("&lt;/span&gt;&lt;/td&gt;")[7].split("&lt;/span&gt;")[0].split("&gt;")[2];
          String TravellerInfoDateOfBirth = SpecificInfo[4] = headerInfo.split("&lt;/span&gt;&lt;/td&gt;")[9].split("&lt;/span&gt;")[0].split("&gt;")[2];
          String TravellerInfoNationality = SpecificInfo[5] = headerInfo.split("&lt;/span&gt;&lt;/td&gt;")[11].split("&lt;/span&gt;")[0].split("&gt;")[2];
  
  
          for(int i = 0; i &lt; TravellerInfo.length ; i++)
              writeToFile(TravellerInfo[i]);
  
          return TravellerInfo;
  </code></pre>
  
  <p>Where headerInfo contains the html snippet as in the first two code examples.</p>
  
  <p>I hope there is a way I do not have to hard code every little change. </p>
  
  <p>Thanks! </p>