Convert/normalize HTML table containing colspan & rowspan...
Posted: Tue Jul 07, 2009 2:38 am
Has anybody already created such a script?
I am looking for a script filter that can take a cleaned HTML table containing colspan & rowspan attributes and un-combine/split them into their own cell.
Input would look something like this:
Output would look like this:
colspan would be pretty easy to handle...simply insert...<td colspan="4">abcd</td>...four times in succession and remove the colspan attributes.
Exp: <td>abcd</td><td>abcd</td><td>abcd</td><td>abcd</td>
rowspan is a little more tricky, as you need to track the placement of the rowspan containing tag and insert it x times in the same location in rows below it.
Thanks for any help,
Brent
I am looking for a script filter that can take a cleaned HTML table containing colspan & rowspan attributes and un-combine/split them into their own cell.
Input would look something like this:
Code: Select all
<table>
<tr>
<td colspan="4">abcd</td>
<td>e</td>
</tr>
<tr>
<td>f</td>
<td>g</td>
<td>h</td>
<td colspan="2">ij</td>
</tr>
<tr>
<td>k</td>
<td>l</td>
<td colspan="2" rowspan="2">mnrs</td>
<td>o</td>
</tr>
<tr>
<td rowspan="2">pu</td>
<td>q</td>
<td>t</td>
</tr>
<tr>
<td>v</td>
<td>w</td>
<td>x</td>
<td>y</td>
</tr>
</table>
Code: Select all
<table>
<tr>
<td>abcd</td>
<td>abcd</td>
<td>abcd</td>
<td>abcd</td>
<td>e</td>
</tr>
<tr>
<td>f</td>
<td>g</td>
<td>h</td>
<td>ij</td>
<td>ij</td>
</tr>
<tr>
<td>k</td>
<td>l</td>
<td>mnrs</td>
<td>mnrs</td>
<td>o</td>
</tr>
<tr>
<td>pu</td>
<td>q</td>
<td>mnrs</td>
<td>mnrs</td>
<td>t</td>
</tr>
<tr>
<td>pu</td>
<td>v</td>
<td>w</td>
<td>x</td>
<td>y</td>
</tr>
</table>
Exp: <td>abcd</td><td>abcd</td><td>abcd</td><td>abcd</td>
rowspan is a little more tricky, as you need to track the placement of the rowspan containing tag and insert it x times in the same location in rows below it.
Thanks for any help,
Brent