http://qs321.pair.com?node_id=88399

larsen has asked for the wisdom of the Perl Monks concerning the following question:

I suppose you were faced at least once with the problem of reverse engineering extremely poor written HTML. In this case the issue is not simply parsing HTML, but guessing the structure (is there's a structure) behind what has been written by some absent minded HTML-coder (artificial, human or a messy combination of both).

Here an example of what I'm coping with:

</tr> </table><html> <body bgcolor="#FFFFFF"> <table border="0" cellspacing="0" cellpadding="0"> <link rel="style +sheet" href="/stile.css" type="text/css"> <tr> <td> <span class="span"> <font color="#FF0000" size="1" face="Verdana, Arial">29/05/200 +1 15:30</font>&nbsp; <font size="1" face="Verdana, Arial">(ACOI - associazione Chirurghi os +pedalieri italiani) <br> <a href="http://www.immedia.it/published/20010529/200105291468 +3.shtml" target="ImmediaPress"><font size="1" face="Verdana, Arial"> <b>IN DUEMILA DA TUTTO IL MONDO AL CONGRESSO DELL'ASSOCIAZIONE DEI CHIRURGHI OSPEDALIERI ITALIANI </b></font> </a> <br> <!-- <font face="verdana, arial, helvetica" size="1"> (IMMEDIAPRESS) Modena e' stata per quattro giorni una citta' i +nternazionale grazie... </font> --> </font> </td> </tr> <tr> <td> <img src="http://www.immedia.it/images/line_home.gif" width=30 +8 height=1 border=0 alt=""><br> </td> </tr> <tr><td height="6"></td></tr> </table> </body> </html><html> <body bgcolor="#FFFFFF">
...and so on.

Now I'm using Adobe GoLive to dig through HTML code, since it provides a tree view that is the best I'm aware of. I ask you if there are common tecniques or general principles to deal with such problems. Thank you.

2001-06-16 Edit by Corion : Fixed link