Hi,
As the subject stats i am trying to convert HTML tables to an array. It is a desktop application basically to performs a http request and is returned with a HTML table. I cant change the way the data is returned. (The data is from FDM remote server and is hard coded).
here is a sample of the table. The table layout will remain the same, only the contents (files) will change.
<table width="100%" border="1">
<tr>
<td>File name<br> </td>
<td>Size<br> </td>
<td>URL<br> </td>
</tr>
<tr>
<td>notepad2.zip</td>
<td>258 KB</td>
<td><a href="http://www.flos-freeware.ch/zip/notepad2.zip">http://www.flos-freeware.ch/zip/notepad2.zip</a></td>
</tr>
<tr>
<td>TeddyGuess.zip</td>
<td>308 KB</td>
<td><a href="http://myhost.com/Guess.zip">http://myhost.com/Guess.zip</a></td>
</tr>
</table>
So ive started and looking at my code i cant help but think there has to be a smarter way!!
public String getCompletedDownloads() {
String tableString = makeRequest("compdlds.req");
tableString = tableString.replaceAll(
"</td><td>Size<br> </td><td>URL<br> </td></tr>", "");
tableString = tableString
.replaceAll(
"<table width=\"100%\" border=\"1\"><tr><td>File name<br> ",
"");
tableString = tableString.replaceAll("</table>", "");
tableString = tableString.replaceAll("<a href=\"", "");
tableString = tableString.replaceAll("\"", "");
return tableString;
}
Please any help would be great.