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


In reply to Reverse engineering HTML by larsen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.