Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert a HTML table to a fixed font textual table?

Tags:

html

text

perl

I have an application in Perl that reads in HTML based mark up and converts it to a textual output. One of the things I have encountered is the need to easily convert a HTML table to a fixed font output.

 <table border="1">
 <tr><td>Hello</td>
     <td>World</td>
 <tr>
     <td>foo</td>
     <td>bar</td>
 </tr></table>

I am looking for something that can take the above table and create something like the following.

 ------------------------------
 | Hello     | World          |
 ------------------------------
 | foo       | bar            |
 ------------------------------

I know how to approach this in Perl and write the process, but I am hoping that there is some library out there that already will do this for me.

like image 336
Tim Koscielski Avatar asked Jan 28 '09 19:01

Tim Koscielski


1 Answers

I've used Text::Table with great success. In combination with something like HTML::TreeBuilder it should be pretty easy.

like image 87
friedo Avatar answered Oct 11 '22 15:10

friedo