Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

convert HTML table to array

807588May 7 2009 — edited May 7 2009
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>&nbsp;</td>
                <td>Size<br>&nbsp;</td>
                <td>URL<br>&nbsp;</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>&nbsp;</td><td>URL<br>&nbsp;</td></tr>", "");
		 tableString = tableString
		 .replaceAll(
		 "<table width=\"100%\" border=\"1\"><tr><td>File name<br>&nbsp;",
		 "");
		 tableString = tableString.replaceAll("</table>", "");
		 tableString = tableString.replaceAll("<a href=\"", "");
		 tableString = tableString.replaceAll("\"", "");
		return tableString;
	}
Please any help would be great.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 4 2009
Added on May 7 2009
8 comments
548 views