Page 1 of 1

Convert/normalize HTML table containing colspan & rowspan...

Posted: Tue Jul 07, 2009 2:38 am
by alnico
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:

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>
Output would look like this:

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>
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

Re: Convert/normalize HTML table containing colspan & rowspan...

Posted: Tue Jul 07, 2009 9:54 am
by DataMystic Support
You'll have to use a VBScript filter to generate this.

Re: Convert/normalize HTML table containing colspan & rowspan...

Posted: Wed Jul 08, 2009 1:47 am
by alnico
Yep, I meant to inquire if anybody that built such a VBScript as it seems somewhat of a standard task.

If not, anybody do it on commission?

Thanks, Brent