I'm looking for a simple converter method. The method would take as input an HTML string that contains a table. The table would contain multiple rows and multiple columns. The method would produce as output a proper CSV String. The language must be in Java as I wish to drop it right into my server-side code.
The method only needs to deal with a minimal number of table related tags. These tags are <tr>, <th>, <td>, colspan, rowspan
Example of method:
<table><tr><th>Header 1</th><th>Header 2</th></tr>
<tr><td>Data 1</td><td>Data 2</td></tr>
Header 1, Header 2
Data 1, Data 2
You can assume all HTML passed in will be valid XHTML with close tags for every start tag in the correct order (a </td> for every </td>).