parsing real HTML is a nightmare.
- HTMLparser.c result/HTML/*: revamped the way the HTML
  parser handles end of tags or end of input
Daniel
diff --git a/ChangeLog b/ChangeLog
index 9a947ab..9ad5c1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Apr 12 17:41:09 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+	* HTMLparser.c result/HTML/*: revamped the way the HTML
+	  parser handles end of tags or end of input
+
 Thu Apr 12 10:50:34 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
 
 	* tree.[ch] : added xmlDocCopyNode for gdome2 support
diff --git a/HTMLparser.c b/HTMLparser.c
index 39447e3..4b3bac8 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -445,7 +445,7 @@
 { "th",		0,	1,	0,	0,	0,	0, "table header cell" },
 { "thead",	0,	1,	0,	0,	0,	0, "table header " },
 { "title",	0,	0,	0,	0,	0,	0, "document title " },
-{ "tr",		0,	1,	0,	0,	0,	0, "table row " },
+{ "tr",		0,	0,	0,	0,	0,	0, "table row " },
 { "tt",		0,	0,	0,	0,	0,	0, "teletype or monospaced text style" },
 { "u",		0,	0,	0,	0,	1,	1, "underlined text style" },
 { "ul",		0,	0,	0,	0,	0,	0, "unordered list " },
@@ -661,6 +661,7 @@
  * htmlAutoCloseOnClose:
  * @ctxt:  an HTML parser context
  * @newtag:  The new tag name
+ * @force:  force the tag closure
  *
  * The HTmL DtD allows an ending tag to implicitely close other tags.
  */
@@ -688,11 +689,7 @@
 	    xmlGenericError(xmlGenericErrorContext,"htmlAutoCloseOnClose: %s closes %s\n", newtag, ctxt->name);
 #endif
         } else {
-	    if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
-		ctxt->sax->error(ctxt->userData,
-		 "Opening and ending tag mismatch: %s and %s\n",
-		                 newtag, ctxt->name);
-	    ctxt->wellFormed = 0;
+	    return;
 	}
 	if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
 	    ctxt->sax->endElement(ctxt->userData, ctxt->name);
@@ -707,6 +704,39 @@
 }
 
 /**
+ * htmlAutoCloseOnEnd:
+ * @ctxt:  an HTML parser context
+ *
+ * Close all remaining tags at the end of the stream
+ */
+static void
+htmlAutoCloseOnEnd(htmlParserCtxtPtr ctxt) {
+    xmlChar *oldname;
+    int i;
+
+    if (ctxt->nameNr == 0)
+	return;
+#ifdef DEBUG
+    xmlGenericError(xmlGenericErrorContext,"Close of stack: %d elements\n", ctxt->nameNr);
+#endif
+
+    for (i = (ctxt->nameNr - 1);i >= 0;i--) {
+#ifdef DEBUG
+        xmlGenericError(xmlGenericErrorContext,"%d : %s\n", i, ctxt->nameTab[i]);
+#endif
+	if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
+	    ctxt->sax->endElement(ctxt->userData, ctxt->name);
+	oldname = htmlnamePop(ctxt);
+	if (oldname != NULL) {
+#ifdef DEBUG
+	    xmlGenericError(xmlGenericErrorContext,"htmlAutoCloseOnEnd: popped %s\n", oldname);
+#endif
+	    xmlFree(oldname);
+	}	
+    }
+}
+
+/**
  * htmlAutoClose:
  * @ctxt:  an HTML parser context
  * @newtag:  The new tag name or NULL
@@ -737,9 +767,8 @@
         }
     }
     if (newtag == NULL) {
-	htmlAutoCloseOnClose(ctxt, BAD_CAST"head");
-	htmlAutoCloseOnClose(ctxt, BAD_CAST"body");
-	htmlAutoCloseOnClose(ctxt, BAD_CAST"html");
+	htmlAutoCloseOnEnd(ctxt);
+	return;
     }
     while ((newtag == NULL) && (ctxt->name != NULL) &&
 	   ((xmlStrEqual(ctxt->name, BAD_CAST"head")) ||
@@ -3266,10 +3295,8 @@
 	     * Fourth : end of the resource
 	     */
 	    else if (CUR == 0) {
-		int level = ctxt->nodeNr;
-		htmlAutoClose(ctxt, NULL);
-		if (level == ctxt->nodeNr)
-		    break;
+		htmlAutoCloseOnEnd(ctxt);
+		break;
 	    }
 
 	    /*
@@ -3439,29 +3466,6 @@
 	if (ctxt->nameNr < depth) break; 
     }	
 
-    if (!IS_CHAR(CUR)) {
-	/************
-	if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
-	    ctxt->sax->error(ctxt->userData,
-	         "Premature end of data in tag %s\n", currentNode);
-	ctxt->wellFormed = 0;
-	 *************/
-
-	/*
-	 * end of parsing of this node.
-	 */
-	nodePop(ctxt);
-	oldname = htmlnamePop(ctxt);
-#ifdef DEBUG
-	xmlGenericError(xmlGenericErrorContext,"Premature end of tag %s : popping out %s\n", name, oldname);
-#endif
-	if (oldname != NULL)
-	    xmlFree(oldname);
-	if (currentNode != NULL)
-	    xmlFree(currentNode);
-	return;
-    }
-
     /*
      * Capture end position and add node
      */
@@ -3472,6 +3476,10 @@
        node_info.node = ctxt->node;
        xmlParserAddNodeInfo(ctxt, &node_info);
     }
+    if (!IS_CHAR(CUR)) {
+	htmlAutoCloseOnEnd(ctxt);
+    }
+
     if (currentNode != NULL)
 	xmlFree(currentNode);
 }
@@ -3556,7 +3564,7 @@
      * autoclose
      */
     if (CUR == 0)
-	htmlAutoClose(ctxt, NULL);
+	htmlAutoCloseOnEnd(ctxt);
 
 
     /*
@@ -3899,7 +3907,7 @@
 	else
 	    avail = in->buf->buffer->use - (in->cur - in->base);
 	if ((avail == 0) && (terminate)) {
-	    htmlAutoClose(ctxt, NULL);
+	    htmlAutoCloseOnEnd(ctxt);
 	    if ((ctxt->nameNr == 0) && (ctxt->instate != XML_PARSER_EOF)) { 
 		/*
 		 * SAX: end of the document processing.
@@ -4077,9 +4085,6 @@
 		    goto done;
 		} else {
 		    ctxt->errNo = XML_ERR_DOCUMENT_END;
-		    if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
-			ctxt->sax->error(ctxt->userData,
-			    "Extra content at the end of the document\n");
 		    ctxt->wellFormed = 0;
 		    ctxt->instate = XML_PARSER_EOF;
 #ifdef DEBUG_PUSH
@@ -4491,7 +4496,7 @@
     }
 done:    
     if ((avail == 0) && (terminate)) {
-	htmlAutoClose(ctxt, NULL);
+	htmlAutoCloseOnEnd(ctxt);
 	if ((ctxt->nameNr == 0) && (ctxt->instate != XML_PARSER_EOF)) { 
 	    /*
 	     * SAX: end of the document processing.
@@ -4555,9 +4560,6 @@
 	    (ctxt->instate != XML_PARSER_EPILOG) &&
 	    (ctxt->instate != XML_PARSER_MISC)) {
 	    ctxt->errNo = XML_ERR_DOCUMENT_END;
-	    if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
-		ctxt->sax->error(ctxt->userData,
-		    "Extra content at the end of the document\n");
 	    ctxt->wellFormed = 0;
 	} 
 	if (ctxt->instate != XML_PARSER_EOF) {
diff --git a/result/HTML/autoclose3.html.err b/result/HTML/autoclose3.html.err
index 09b9e33..e69de29 100644
--- a/result/HTML/autoclose3.html.err
+++ b/result/HTML/autoclose3.html.err
@@ -1,3 +0,0 @@
-./test/HTML/autoclose3.html:4: error: Opening and ending tag mismatch: body and ul
-
-^
diff --git a/result/HTML/autoclose3.html.sax b/result/HTML/autoclose3.html.sax
index e8ed330..25e06ea 100644
--- a/result/HTML/autoclose3.html.sax
+++ b/result/HTML/autoclose3.html.sax
@@ -13,7 +13,6 @@
 SAX.characters(item 2
 , 7)
 SAX.endElement(li)
-SAX.error: Opening and ending tag mismatch: body and ul
 SAX.endElement(ul)
 SAX.endElement(body)
 SAX.endElement(html)
diff --git a/result/HTML/doc3.htm b/result/HTML/doc3.htm
index c5a4f66..0738497 100644
--- a/result/HTML/doc3.htm
+++ b/result/HTML/doc3.htm
@@ -803,15 +803,15 @@
 <!-- <input type="submit" name="npunsubscribe" value="Unsubscribe" style="font-size: xx-small; font-family: Verdana; font-weight: bold; color: #ffffff; background-color: #000000;"> -->
 </font>
 </form>
-<font size="1"><form action="http://bp6.gamesquad.net/cgi-bin/news/viewnews.cgi?search" method="post">Search news<br>
+<font size="1">
+<form action="http://bp6.gamesquad.net/cgi-bin/news/viewnews.cgi?search" method="post">Search news<br>
 <input name="searchstring" size="13">
 <br>
 <input name="submit" style="BACKGROUND-COLOR: #000000; COLOR: #ffffff; FONT-FAMILY: Verdana; FONT-SIZE: xx-small; FONT-WEIGHT: bold" type="submit" value="Submit">
 <br>
 <a href="http://bp6.gamesquad.net/cgi-bin/news/viewnews.cgi?newsall">News 

             archive</a>
-</form></font>
-</center></td></tr></tbody></table>
+</form>
 <!--				<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%" BGCOLOR="silver">

 					<TR>

 						<TD WIDTH="100%">

@@ -851,19 +851,21 @@
 							}

 							// -->

 							</script>
-<b><noscript></noscript></b>
+<b><noscript>
 <a href="http://www.goto.com/d/search/ssn/?fromGIF=true" target="_blank"><img align="bottom" border="0" height="90" ismap src="doc3_files/100x90.gif" width="100"></a>
 <b><a href="http://www.goto.com/d/search/ssn/?fromGIF=true" target="_blank"></a></b>
 <b></b>
 <b><!-- END GoTo.com Search Box --></b>
-<!-- Pricewatch Search Box --><form action="http://www.pricewatch.com/search/search.asp" method="get" target="_Blank"><center><p>
+<!-- Pricewatch Search Box --><form action="http://www.pricewatch.com/search/search.asp" method="get" target="_Blank">
+<center>
+<p>
 <b><font color="white" face="ARIAL, HELVETICA" size="1">PC Price 

             Search<br>
 </font></b>
 <input maxlength="30" name="criteria" size="10">
 <br>
 <input name="submit" style="BACKGROUND-COLOR: #000000; COLOR: #ffffff; FONT-FAMILY: Verdana; FONT-SIZE: xx-small; FONT-WEIGHT: bold" type="submit" value="Search">
-</p></center></form>
+</p>
 <!-- Pricewatch Search Box --><a href="http://www.puicorp.com/bp6specials.htm" target="_BLANK"><img src="doc3_files/puibp6.gif"></a>
 <br>
 <br>
@@ -875,9 +877,7 @@
 <br>BP6.COM 

             Special<br>Code:BP6-hd</font>
 </a>
-</td></tr></tbody></table>
-</center></td>
-</tr></tbody></table>
+</center>
 <table bgcolor="silver" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%"><tbody><tr><td width="100%"> </td></tr></tbody></table>
 <!--	</TABLE>--><center></center>
 <tr><td colspan="3" valign="TOP" height="70"> </td></tr>
@@ -889,7 +889,14 @@
 </p></td></tr>
 <!--	<TR>		<TD WIDTH="780">			<P ALIGN="CENTER"><FONT SIZE="1" COLOR="#999999" FACE="Verdana,arial">Site design by Tim Brinkley</FONT>		</TD>	</TR> -->
 </tbody></table>
-</div>
 <script> window.open=NS_ActualOpen; </script>
+</form>
+</noscript></b>
+</td></tr></tbody></table>
+</font>
+</center></td></tr></tbody></table>
+</center></td>
+</tr></tbody></table>
+</div>
 </body>
 </html>
diff --git a/result/HTML/doc3.htm.err b/result/HTML/doc3.htm.err
index 46aae6f..76609fc 100644
--- a/result/HTML/doc3.htm.err
+++ b/result/HTML/doc3.htm.err
@@ -3,19 +3,19 @@
                                  ^
 ./test/HTML/doc3.htm:47: error: htmlParseEntityRef: expecting ';'
  href="http://ads.gamesquad.net/addclick.exe/adclick.cgi?REGION=game|tech|ent&i
-                                                                                ^
+                                                                              ^
 ./test/HTML/doc3.htm:47: error: htmlParseEntityRef: expecting ';'
 _top"><img src="http://ads.gamesquad.net/addclick.exe/adcycle.cgi?group=52&medi
-                                                                                ^
+                                                                              ^
 ./test/HTML/doc3.htm:47: error: htmlParseEntityRef: expecting ';'
 ><img src="http://ads.gamesquad.net/addclick.exe/adcycle.cgi?group=52&media=1&i
-                                                                                ^
+                                                                              ^
 ./test/HTML/doc3.htm:140: error: error parsing attribute name
                         width=70 Gentus?.?></A><BR><A 
                                        ^
 ./test/HTML/doc3.htm:143: error: Unexpected end tag : p
   </P></TD></TR></TBODY></TABLE></CENTER></TD></TR></TBODY></TABLE></CENTER></P
-                                                                                ^
+                                                                              ^
 ./test/HTML/doc3.htm:231: error: Unexpected end tag : font
             Specials<BR><BR></FONT></A><BR></FONT></A><B><FONT color=yellow 
                                                   ^
@@ -24,25 +24,37 @@
                                                       ^
 ./test/HTML/doc3.htm:742: error: htmlParseEntityRef: expecting ';'
 er=0 alt="Advertisement" src="http://ads.adflight.com/ad_static.asp?pid=2097&si
-                                                                                ^
+                                                                              ^
 ./test/HTML/doc3.htm:742: error: htmlParseEntityRef: expecting ';'
 Advertisement" src="http://ads.adflight.com/ad_static.asp?pid=2097&sid=1881&asi
-                                                                                ^
+                                                                              ^
 ./test/HTML/doc3.htm:742: error: Unexpected end tag : li
 light.com/ad_static.asp?pid=2097&sid=1881&asid=7708"></a></IFRAME></CENTER></LI
-                                                                                ^
+                                                                              ^
 ./test/HTML/doc3.htm:742: error: Unexpected end tag : font
 om/ad_static.asp?pid=2097&sid=1881&asid=7708"></a></IFRAME></CENTER></LI></FONT
-                                                                                ^
+                                                                              ^
 ./test/HTML/doc3.htm:742: error: Unexpected end tag : p
 =7708"></a></IFRAME></CENTER></LI></FONT></TD></TR></TBODY></TABLE></CENTER></P
-                                                                                ^
+                                                                              ^
 ./test/HTML/doc3.htm:767: error: Opening and ending tag mismatch: font and form
             archive</A></FONT> </FORM></CENTER></TD></TR></TBODY></TABLE><!--		
                               ^
-./test/HTML/doc3.htm:767: error: Unexpected end tag : form
+./test/HTML/doc3.htm:767: error: Opening and ending tag mismatch: center and font
             archive</A></FONT> </FORM></CENTER></TD></TR></TBODY></TABLE><!--		
-                                      ^
+                                               ^
+./test/HTML/doc3.htm:767: error: Opening and ending tag mismatch: td and font
+            archive</A></FONT> </FORM></CENTER></TD></TR></TBODY></TABLE><!--		
+                                                    ^
+./test/HTML/doc3.htm:767: error: Opening and ending tag mismatch: tr and font
+            archive</A></FONT> </FORM></CENTER></TD></TR></TBODY></TABLE><!--		
+                                                         ^
+./test/HTML/doc3.htm:767: error: Opening and ending tag mismatch: tbody and font
+            archive</A></FONT> </FORM></CENTER></TD></TR></TBODY></TABLE><!--		
+                                                                 ^
+./test/HTML/doc3.htm:767: error: Opening and ending tag mismatch: table and font
+            archive</A></FONT> </FORM></CENTER></TD></TR></TBODY></TABLE><!--		
+                                                                         ^
 ./test/HTML/doc3.htm:790: error: Unexpected end tag : iframe
 							document.write("42DF8478957377></IFRAME>");
                                                ^
@@ -61,7 +73,7 @@
 ./test/HTML/doc3.htm:815: error: Unexpected end tag : a
             </A></A></B><B></NOSCRIPT></B><B><!-- END GoTo.com Search Box --></
                     ^
-./test/HTML/doc3.htm:815: error: Unexpected end tag : noscript
+./test/HTML/doc3.htm:815: error: Opening and ending tag mismatch: noscript and b
             </A></A></B><B></NOSCRIPT></B><B><!-- END GoTo.com Search Box --></
                                       ^
 ./test/HTML/doc3.htm:821: error: Opening and ending tag mismatch: form and center
@@ -70,36 +82,48 @@
 ./test/HTML/doc3.htm:828: error: Unexpected end tag : p
             Special<BR>Code:BP6-hd</FONT></A> </P></CENTER></TD></TR></TBODY></
                                                   ^
-./test/HTML/doc3.htm:828: error: Opening and ending tag mismatch: center and td
+./test/HTML/doc3.htm:828: error: Opening and ending tag mismatch: td and form
             Special<BR>Code:BP6-hd</FONT></A> </P></CENTER></TD></TR></TBODY></
-                                                           ^
-./test/HTML/doc3.htm:828: error: Opening and ending tag mismatch: center and tbody
+                                                                ^
+./test/HTML/doc3.htm:828: error: Opening and ending tag mismatch: tr and form
             Special<BR>Code:BP6-hd</FONT></A> </P></CENTER></TD></TR></TBODY></
-                                                           ^
-./test/HTML/doc3.htm:828: error: Opening and ending tag mismatch: center and table
+                                                                     ^
+./test/HTML/doc3.htm:828: error: Opening and ending tag mismatch: tbody and form
             Special<BR>Code:BP6-hd</FONT></A> </P></CENTER></TD></TR></TBODY></
-                                                           ^
+                                                                             ^
+./test/HTML/doc3.htm:828: error: Opening and ending tag mismatch: table and form
+        Special<BR>Code:BP6-hd</FONT></A> </P></CENTER></TD></TR></TBODY></TABL
+                                                                              ^
 ./test/HTML/doc3.htm:834: error: Unexpected end tag : p
 width="100%">&nbsp;</TD></TR></TBODY></TABLE></P></CENTER></TR></TBODY></TABLE>
                                                  ^
-./test/HTML/doc3.htm:834: error: Unexpected end tag : center
+./test/HTML/doc3.htm:834: error: Opening and ending tag mismatch: center and form
 width="100%">&nbsp;</TD></TR></TBODY></TABLE></P></CENTER></TR></TBODY></TABLE>
                                                           ^
-./test/HTML/doc3.htm:834: error: Unexpected end tag : tr
+./test/HTML/doc3.htm:834: error: Opening and ending tag mismatch: tr and form
 width="100%">&nbsp;</TD></TR></TBODY></TABLE></P></CENTER></TR></TBODY></TABLE>
                                                                ^
-./test/HTML/doc3.htm:834: error: Unexpected end tag : tbody
+./test/HTML/doc3.htm:834: error: Opening and ending tag mismatch: tbody and form
 width="100%">&nbsp;</TD></TR></TBODY></TABLE></P></CENTER></TR></TBODY></TABLE>
                                                                        ^
-./test/HTML/doc3.htm:834: error: Unexpected end tag : table
+./test/HTML/doc3.htm:834: error: Opening and ending tag mismatch: table and form
 width="100%">&nbsp;</TD></TR></TBODY></TABLE></P></CENTER></TR></TBODY></TABLE>
-                                                                               ^
-./test/HTML/doc3.htm:835: error: Unexpected end tag : td
+                                                                              ^
+./test/HTML/doc3.htm:835: error: Opening and ending tag mismatch: td and form
 <CENTER></CENTER></TD></TR><TR><TD COLSPAN="3" VALIGN="TOP" 
                       ^
-./test/HTML/doc3.htm:835: error: Unexpected end tag : tr
+./test/HTML/doc3.htm:835: error: Opening and ending tag mismatch: tr and form
 <CENTER></CENTER></TD></TR><TR><TD COLSPAN="3" VALIGN="TOP" 
                            ^
-./test/HTML/doc3.htm:836: error: Unexpected end tag : table
+./test/HTML/doc3.htm:836: error: Opening and ending tag mismatch: table and form
 HEIGHT="70">&nbsp;</TD> </TR></TABLE>
                                     ^
+./test/HTML/doc3.htm:844: error: Opening and ending tag mismatch: div and form
+,arial">Site design by Tim Brinkley</FONT>		</TD>	</TR> --></TBODY></TABLE></DI
+                                                                              ^
+./test/HTML/doc3.htm:846: error: Opening and ending tag mismatch: body and form
+</BODY></HTML>
+       ^
+./test/HTML/doc3.htm:846: error: Opening and ending tag mismatch: html and form
+</BODY></HTML>
+             ^
diff --git a/result/HTML/doc3.htm.sax b/result/HTML/doc3.htm.sax
index de3a682..a7eb7f8 100644
--- a/result/HTML/doc3.htm.sax
+++ b/result/HTML/doc3.htm.sax
Binary files differ
diff --git a/result/HTML/entities.html.err b/result/HTML/entities.html.err
index a2bd6d0..ca98132 100644
--- a/result/HTML/entities.html.err
+++ b/result/HTML/entities.html.err
@@ -1,9 +1,9 @@
 ./test/HTML/entities.html:1: error: htmlParseEntityRef: expecting ';'
 <p tst="a&amp;b" tst2="a&b" tst3="a & b">
-                          ^
+                         ^
 ./test/HTML/entities.html:1: error: htmlParseEntityRef: no name
 <p tst="a&amp;b" tst2="a&b" tst3="a & b">
-                                     ^
+                                    ^
 ./test/HTML/entities.html:3: error: htmlParseEntityRef: expecting ';'
 a&b
   ^
diff --git a/result/HTML/test3.html b/result/HTML/test3.html
index 597a1a4..4b916c7 100644
--- a/result/HTML/test3.html
+++ b/result/HTML/test3.html
@@ -38,7 +38,8 @@
 <dt><h4>Class <a href="ProblemDomain.Note.html#ProblemDomain.Note">ProblemDomain.Note</a>
 </h4></dt>
 </dl>
-<h4><b>Links</b></h4>
+<h4>
+<b>Links</b>

 <ul><li>
 <b>Link to </b>
 <a href="HumanInterface.Package.html#HumanInterface.Package">HumanInterface</a>
@@ -54,5 +55,6 @@
 <a href="DataManagement.Package.html#DataManagement.Package">DataManagement</a>
 </li></ul>
 <dir></dir>
+</h4>
 </body>
 </html>
diff --git a/result/HTML/test3.html.err b/result/HTML/test3.html.err
index 37414fc..a8c9967 100644
--- a/result/HTML/test3.html.err
+++ b/result/HTML/test3.html.err
@@ -7,6 +7,6 @@
 ./test/HTML/test3.html:27: error: Opening and ending tag mismatch: h4 and b
 <h4><b>Links</h4></b>
                  ^
-./test/HTML/test3.html:27: error: Unexpected end tag : b
-<h4><b>Links</h4></b>
-                    ^
+./test/HTML/test3.html:34: error: Opening and ending tag mismatch: html and h4
+</html>
+      ^
diff --git a/result/HTML/test3.html.sax b/result/HTML/test3.html.sax
index 1f76e50..bb96955 100644
--- a/result/HTML/test3.html.sax
+++ b/result/HTML/test3.html.sax
@@ -171,9 +171,7 @@
 SAX.characters(Links, 5)
 SAX.error: Opening and ending tag mismatch: h4 and b
 SAX.endElement(b)
-SAX.endElement(h4)
-SAX.error: Unexpected end tag : b
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(ul)
 SAX.startElement(li)
@@ -185,11 +183,11 @@
 SAX.endElement(a)
 SAX.endElement(li)
 SAX.endElement(ul)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(dir)
 SAX.endElement(dir)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(ul)
 SAX.startElement(li)
@@ -201,11 +199,11 @@
 SAX.endElement(a)
 SAX.endElement(li)
 SAX.endElement(ul)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(dir)
 SAX.endElement(dir)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(ul)
 SAX.startElement(li)
@@ -217,14 +215,16 @@
 SAX.endElement(a)
 SAX.endElement(li)
 SAX.endElement(ul)
-SAX.ignorableWhitespace(

+SAX.characters(

 , 2)
 SAX.startElement(dir)
 SAX.endElement(dir)
+SAX.characters(

+, 2)
+SAX.error: Opening and ending tag mismatch: html and h4
 SAX.ignorableWhitespace(

 , 2)
+SAX.endElement(h4)
 SAX.endElement(body)
 SAX.endElement(html)
-SAX.ignorableWhitespace(

-, 2)
 SAX.endDocument()
diff --git a/result/HTML/wired.html b/result/HTML/wired.html
index 6653097..9f4a78e 100644
--- a/result/HTML/wired.html
+++ b/result/HTML/wired.html
@@ -127,17 +127,17 @@
 <tr><td bgcolor="#CCFFCC"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#000000"><a href="/news/news/reuters/sports/">Sports</a></font></td></tr>
 <tr><td bgcolor="#99FF99"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#000000"><a href="/news/news/reuters/business/">Finance</a></font></td></tr>
 <!-- End upper left nav --><!-- Begin lower Left Nav --><tr><td bgcolor="#FF0000"><font face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b><font size="1">FREE DELIVERY</font></b></font></td></tr>
-<tr><td bgcolor="#99FF99"><table cellspacing="0" cellpadding="0" border="0"><tr>
-<td bgcolor="#99FF99"><form action="http://r.hotwired.com/r/hw_wm_r_nav_nwsltr/http://perl.hotwired.com/massmail/cgiParser.cgi" method="get" target="_top">
+<tr><td bgcolor="#99FF99"><table cellspacing="0" cellpadding="0" border="0">
+<tr><td bgcolor="#99FF99"><form action="http://r.hotwired.com/r/hw_wm_r_nav_nwsltr/http://perl.hotwired.com/massmail/cgiParser.cgi" method="get" target="_top">
 <input type="hidden" name="success_page" value="http://www.hotwired.com/email/signup/wirednews-ascii.html">
 <input type="hidden" name="failure_page" value="http://www.hotwired.com/email/signup/wirednews-ascii.html">
 <input type="hidden" name="LIST" value="wn_ascii">
 <input type="hidden" name="SOURCE" value="other">
 <input type="hidden" name="ACTION" value="subscribe">
 <input type="TEXT" name="from" size="10" value="enter email">&nbsp;
-</form></td>
-<td valign="top" bgcolor="#99FF99"><input type="SUBMIT" name="SUBMIT" value="GO"></td>
-</tr></table></td></tr>
+ 
+		<td valign="top" bgcolor="#99FF99"><input type="SUBMIT" name="SUBMIT" value="GO"></td>
+</form></td></tr>
 <tr><td bgcolor="#FF0000"><font face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b><font size="1">STOCKS</font></b></font></td></tr>
 <tr><td bgcolor="#99FF99"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Get Quote:</font></td></tr>
 <tr><td bgcolor="#99FF99" marginwidth="0" marginheight="0"><form method="get" action="http://r.wired.com/r/10020/http://stocks.wired.com/stocks_quotes.asp">
@@ -206,7 +206,6 @@
 
  </option>
 </select></font>
-</form></td></tr>
 <tr align="left" valign="top"><td valign="top" bgcolor="#CCFFCC">
 <input type="submit" value="GO">
 <img src="http://barnesandnoble.bfast.com/booklink/serve?sourceid=383471&amp;is_search=Y" border="0" align="top">
@@ -219,7 +218,7 @@
 </font>
 <br clear="all">
 </p></td></tr>
-</table></td></tr>
+</form></td></tr>
 <!-- END B&N spot --><!-- BEGIN MAGAZINE SPOT --><tr><td bgcolor="#000000"><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="1"><b>WIRED 
       MAGAZINE </b></font></td></tr>
 <tr><td bgcolor="#FFFF99" align="CENTER"><font face="verdana, arial, helvetica, sans-serif" size="1">
@@ -272,11 +271,7 @@
 </font>
 <br>
 <!-- TRACKING --><img src="http://www.wired.com/special/modx/news.gif" height="1" width="1" alt="">
-</font>
-</td></tr>
-</table>
-<!-- end lower left side Navigation --><!-- CONTENT TABLE --><table border="0" width="447" cellspacing="0" cellpadding="0" bordercolor="#66FF00">
-<tr>
+<!-- end lower left side Navigation --><!-- CONTENT TABLE --><table border="0" width="447" cellspacing="0" cellpadding="0" bordercolor="#66FF00"><tr>
 <td valign="TOP" align="LEFT" rowspan="2">
 <img src="http://static.wired.com/news/images/spacer.gif" height="1" width="15" alt="">
 <br>
@@ -316,10 +311,6 @@
 <font size="1" face="Arial, Geneva, sans-serif" color="#000000">Readers on Apple's G4 ... AOL's passwords ... MS vs. Linux.</font>
 <br>
 <br>
-</font>
-</font>
-</td>
-</tr>
 <!-- Commentary Frag End --><tr>
 <td align="left" bgcolor="#000000">&nbsp;</td>
 <td bgcolor="#000000"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b>CURRENT HOO-HA</b></font></td>
@@ -390,9 +381,8 @@
 <font size="2" face="Arial,Helvetica, sans-serif"><b><a href="/news/exec/0,1370,,00.html">Executive Summary</a></b></font>
 <br>
 <font size="1" face="Arial, Helvetica, sans-serif" color="#000000">CEOs, COOs, CIOs unite.  <br>
-<i>Sponsored by <a href="http://r.wired.com/r/wn_exec_r_vign/http://www.vignette.com/" style="text-decoration:none"><font color="#000000">Vignette</font></a>
-</i>
-</font>
+<i>Sponsored by <a href="http://r.wired.com/r/wn_exec_r_vign/http://www.vignette.com/" style="text-decoration:none">
+<font color="#000000">Vignette</font>
 <br>
 <br>
 <font size="2" face="Arial,Helvetica, sans-serif"><b><a href="/news/school/0,1383,,00.html">Making the Grade</a></b></font>
@@ -409,10 +399,8 @@
 <font size="1" face="Arial, Helvetica, sans-serif" color="#000000">An IS/IT resource <br>
 <i>Sponsored by <a href="http://r.wired.com/r/wn_is_r_ssec/http://ad.doubleclick.net/clk;653163;3599571;s?http://www.sprintbiz.com/s
 ervlet/appservlet?from=/wired/sprint/&amp;template=/security/security.html&amp;SITE=
-wired.com&amp;BANNER=Sprint" style="text-decoration:none"><font color="#000000">Sprint</font></a>
-</i>
-</font>
-</font>
+wired.com&amp;BANNER=Sprint" style="text-decoration:none">
+<font color="#000000">Sprint</font>
 <br>
 <br>
 <font size="2" face="Arial,Helvetica, sans-serif"><b><a href="/news/y2k/0,1360,,00.html">Y2K Watch</a></b></font>
@@ -423,16 +411,6 @@
 <br>
 <font face="Arial, Helvetica, sans-serif" size="2"><b><i><a href="/news/special_reports/1,1293,,00.html">More Hoo-Ha</a></i></b></font>
 <br>&nbsp;<br>
-</font>
-</font>
-</font>
-</font>
-</font>
-</font>
-</font>
-</font>
-</td>
-</tr>
 <!-- start of Gen News --><tr>
 <td bgcolor="#000000">&nbsp;</td>
 <td bgcolor="#000000"><font size="1" face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><b>MEANWHILE...</b></font></td>
@@ -456,9 +434,7 @@
 <br>
 </td>
 </tr>
-<!-- end of Gen News -->
-</table>
-<font size="1">&nbsp;<br>
+<!-- end of Gen News --><font size="1">&nbsp;<br>
 </font>
 <br>
 <font face="Verdana, Arial, Geneva, sans-serif" size="2"><b><i>Other Top Stories</i></b></font>
@@ -586,10 +562,7 @@
 <font face="geneva, arial" size="2">BBC News</font>
 <br>
 <br>
-<!-- SQL above --><!-- - - - - - - - - - - - - -->
-</td>
-</tr>
-<tr>
+<!-- SQL above --><!-- - - - - - - - - - - - - --><tr>
 <td valign="TOP" align="LEFT">
 <img src="http://static.wired.com/news/images/spacer.gif" height="1" width="280" alt="">
 <br>
@@ -627,7 +600,35 @@
 <td valign="TOP" align="LEFT"><img src="http://static.wired.com/news/images/spacer.gif" height="1" width="5" alt=""></td>
 <td valign="TOP" align="LEFT"></td>
 </tr>
-</table>
 <br>
+</font>
+</a>
+</i>
+</font>
+</font>
+</a>
+</i>
+</font>
+</font>
+</font>
+</font>
+</font>
+</font>
+</font>
+</font>
+</td>
+</tr>
+</font>
+</font>
+</td>
+</tr>
+</table>
+</td>
+</tr></table>
+</font>
+</td></tr>
+</table></td></tr>
+</table></td></tr>
+</table>
 </body>
 </html>
diff --git a/result/HTML/wired.html.err b/result/HTML/wired.html.err
index e9e588d..86bd1c2 100644
--- a/result/HTML/wired.html.err
+++ b/result/HTML/wired.html.err
@@ -1,162 +1,162 @@
 ./test/HTML/wired.html:6: error: htmlParseEntityRef: expecting ';'
 <FORM METHOD=GET ACTION="http://nsads.hotwired.com/event.ng/Type=click&ProfileI
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:6: error: htmlParseEntityRef: expecting ';'
 D=GET ACTION="http://nsads.hotwired.com/event.ng/Type=click&ProfileID=9688&RunI
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:6: error: htmlParseEntityRef: expecting ';'
 N="http://nsads.hotwired.com/event.ng/Type=click&ProfileID=9688&RunID=14074&AdI
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:6: error: htmlParseEntityRef: expecting ';'
 s.hotwired.com/event.ng/Type=click&ProfileID=9688&RunID=14074&AdID=22584&GroupI
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:6: error: htmlParseEntityRef: expecting ';'
 com/event.ng/Type=click&ProfileID=9688&RunID=14074&AdID=22584&GroupID=1&FamilyI
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:6: error: htmlParseEntityRef: expecting ';'
 pe=click&ProfileID=9688&RunID=14074&AdID=22584&GroupID=1&FamilyID=2684&TagValue
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:52: error: htmlParseEntityRef: expecting ';'
 " align="RIGHT"><a href="http://nsads.hotwired.com/event.ng/Type=click&ProfileI
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:52: error: htmlParseEntityRef: expecting ';'
 GHT"><a href="http://nsads.hotwired.com/event.ng/Type=click&ProfileID=5597&RunI
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:52: error: htmlParseEntityRef: expecting ';'
 f="http://nsads.hotwired.com/event.ng/Type=click&ProfileID=5597&RunID=17167&AdI
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:52: error: htmlParseEntityRef: expecting ';'
 s.hotwired.com/event.ng/Type=click&ProfileID=5597&RunID=17167&AdID=22588&GroupI
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:52: error: htmlParseEntityRef: expecting ';'
 com/event.ng/Type=click&ProfileID=5597&RunID=17167&AdID=22588&GroupID=1&FamilyI
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:52: error: htmlParseEntityRef: expecting ';'
 pe=click&ProfileID=5597&RunID=17167&AdID=22588&GroupID=1&FamilyID=3228&TagValue
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:70: error: Tag nobr invalid
 <td bgcolor="#FF0000" align="left" valign="center"><nobr><img src="http://stati
                                                         ^
 ./test/HTML/wired.html:89: error: htmlParseEntityRef: expecting ';'
 on value="http://search.hotwired.com/search97/s97.vts?Action=FilterSearch&Filte
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:89: error: htmlParseEntityRef: expecting ';'
 d.com/search97/s97.vts?Action=FilterSearch&Filter=docs_filter.hts&ResultTemplat
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:89: error: htmlParseEntityRef: expecting ';'
 ction=FilterSearch&Filter=docs_filter.hts&ResultTemplate=vignette.hts&Collectio
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:89: error: htmlParseEntityRef: expecting ';'
 Filter=docs_filter.hts&ResultTemplate=vignette.hts&Collection=vignette&QueryMod
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:89: error: htmlParseEntityRef: expecting ';'
 ter.hts&ResultTemplate=vignette.hts&Collection=vignette&QueryMode=Internet&Quer
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:90: error: htmlParseEntityRef: expecting ';'
 on value="http://search.hotwired.com/search97/s97.vts?Action=FilterSearch&Filte
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:90: error: htmlParseEntityRef: expecting ';'
 d.com/search97/s97.vts?Action=FilterSearch&Filter=docs_filter.hts&ResultTemplat
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:90: error: htmlParseEntityRef: expecting ';'
 tion=FilterSearch&Filter=docs_filter.hts&ResultTemplate=webmonkey.hts&Collectio
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:90: error: htmlParseEntityRef: expecting ';'
 lter=docs_filter.hts&ResultTemplate=webmonkey.hts&Collection=webmonkey&QueryMod
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:90: error: htmlParseEntityRef: expecting ';'
 r.hts&ResultTemplate=webmonkey.hts&Collection=webmonkey&QueryMode=Internet&Quer
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:91: error: htmlParseEntityRef: expecting ';'
 ="http://search.hotwired.com/search97/s97.vts?collection=webmonkey_guides&Actio
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:91: error: htmlParseEntityRef: expecting ';'
 ired.com/search97/s97.vts?collection=webmonkey_guides&Action=FilterSearch&filte
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:91: error: htmlParseEntityRef: expecting ';'
 ction=webmonkey_guides&Action=FilterSearch&filter=docs_filter.hts&ResultTemplat
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:91: error: htmlParseEntityRef: expecting ';'
 ilterSearch&filter=docs_filter.hts&ResultTemplate=webmonkey_guides.hts&QueryMod
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:91: error: htmlParseEntityRef: expecting ';'
 ter=docs_filter.hts&ResultTemplate=webmonkey_guides.hts&QueryMode=Internet&Quer
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:92: error: htmlParseEntityRef: expecting ';'
 on value="http://search.hotwired.com/search97/s97.vts?collection=hotwired&Actio
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:92: error: htmlParseEntityRef: expecting ';'
 rch.hotwired.com/search97/s97.vts?collection=hotwired&Action=FilterSearch&filte
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:92: error: htmlParseEntityRef: expecting ';'
 ts?collection=hotwired&Action=FilterSearch&filter=docs_filter.hts&ResultTemplat
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:92: error: htmlParseEntityRef: expecting ';'
 ilterSearch&filter=docs_filter.hts&ResultTemplate=hotwired_archive.hts&QueryMod
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:92: error: htmlParseEntityRef: expecting ';'
 ter=docs_filter.hts&ResultTemplate=hotwired_archive.hts&QueryMode=Internet&Quer
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:93: error: htmlParseEntityRef: expecting ';'
 on value="http://search.hotwired.com/search97/s97.vts?Action=FilterSearch&Filte
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:93: error: htmlParseEntityRef: expecting ';'
 d.com/search97/s97.vts?Action=FilterSearch&Filter=docs_filter.hts&ResultTemplat
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:93: error: htmlParseEntityRef: expecting ';'
 ction=FilterSearch&Filter=docs_filter.hts&ResultTemplate=magazine.hts&Collectio
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:93: error: htmlParseEntityRef: expecting ';'
 Filter=docs_filter.hts&ResultTemplate=magazine.hts&Collection=magazine&QueryMod
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:93: error: htmlParseEntityRef: expecting ';'
 ter.hts&ResultTemplate=magazine.hts&Collection=magazine&QueryMode=Internet&Quer
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:94: error: htmlParseEntityRef: expecting ';'
 on value="http://search.hotwired.com/search97/s97.vts?Action=FilterSearch&Filte
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:94: error: htmlParseEntityRef: expecting ';'
 d.com/search97/s97.vts?Action=FilterSearch&Filter=docs_filter.hts&ResultTemplat
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:94: error: htmlParseEntityRef: expecting ';'
 tion=FilterSearch&Filter=docs_filter.hts&ResultTemplate=animation.hts&Collectio
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:94: error: htmlParseEntityRef: expecting ';'
 lter=docs_filter.hts&ResultTemplate=animation.hts&Collection=animation&QueryMod
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:94: error: htmlParseEntityRef: expecting ';'
 r.hts&ResultTemplate=animation.hts&Collection=animation&QueryMode=Internet&Quer
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:95: error: htmlParseEntityRef: expecting ';'
 option value="http://search.hotwired.com/search97/s97.vts?collection=suck&Actio
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:95: error: htmlParseEntityRef: expecting ';'
 /search.hotwired.com/search97/s97.vts?collection=suck&Action=FilterSearch&filte
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:95: error: htmlParseEntityRef: expecting ';'
 97.vts?collection=suck&Action=FilterSearch&filter=docs_filter.hts&ResultTemplat
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:95: error: htmlParseEntityRef: expecting ';'
 uck&Action=FilterSearch&filter=docs_filter.hts&ResultTemplate=suck.hts&QueryMod
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:95: error: htmlParseEntityRef: expecting ';'
 erSearch&filter=docs_filter.hts&ResultTemplate=suck.hts&QueryMode=Internet&Quer
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:96: error: htmlParseEntityRef: expecting ';'
 lue="http://search.hotwired.com/search97/s97.vts?collection=uber_hotwired&Actio
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:96: error: htmlParseEntityRef: expecting ';'
 otwired.com/search97/s97.vts?collection=uber_hotwired&Action=FilterSearch&filte
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:96: error: htmlParseEntityRef: expecting ';'
 llection=uber_hotwired&Action=FilterSearch&filter=docs_filter.hts&ResultTemplat
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:96: error: htmlParseEntityRef: expecting ';'
 n=FilterSearch&filter=docs_filter.hts&ResultTemplate=uber_hotwired.hts&QueryMod
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:96: error: htmlParseEntityRef: expecting ';'
 filter=docs_filter.hts&ResultTemplate=uber_hotwired.hts&QueryMode=Internet&Quer
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:97: error: htmlParseEntityRef: expecting ';'
  <option value="http://www.hotbot.com/?SM=MC&DV=0&LG=any&RD=RG&DC=10&DE=2&_v=2&
                                                ^
@@ -177,40 +177,55 @@
                                                                             ^
 ./test/HTML/wired.html:97: error: htmlParseEntityRef: expecting ';'
 option value="http://www.hotbot.com/?SM=MC&DV=0&LG=any&RD=RG&DC=10&DE=2&_v=2&OP
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:97: error: htmlParseEntityRef: expecting ';'
 lue="http://www.hotbot.com/?SM=MC&DV=0&LG=any&RD=RG&DC=10&DE=2&_v=2&OPs=MDRTP&M
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:165: error: Opening and ending tag mismatch: td and form
 </td> 
      ^
-./test/HTML/wired.html:170: error: Unexpected end tag : form
+./test/HTML/wired.html:170: error: Opening and ending tag mismatch: tr and form
 	</tr>    </form>
-                ^
+      ^
+./test/HTML/wired.html:171: error: Opening and ending tag mismatch: table and td
+</table></td>
+        ^
 ./test/HTML/wired.html:244: error: Opening and ending tag mismatch: td and form
  </select></font></td></tr>
                       ^
+./test/HTML/wired.html:244: error: Opening and ending tag mismatch: tr and form
+ </select></font></td></tr>
+                          ^
 ./test/HTML/wired.html:248: error: htmlParseEntityRef: expecting ';'
 MG SRC="http://barnesandnoble.bfast.com/booklink/serve?sourceid=383471&is_searc
-                                                                                ^
-./test/HTML/wired.html:265: error: Unexpected end tag : form
-        </tr>  </form>
-                     ^
+                                                                              ^
+./test/HTML/wired.html:266: error: Opening and ending tag mismatch: table and td
+        </table>
+               ^
 ./test/HTML/wired.html:346: error: Opening and ending tag mismatch: td and font
 </td>
     ^
+./test/HTML/wired.html:347: error: Opening and ending tag mismatch: tr and font
+  </tr>
+      ^
+./test/HTML/wired.html:349: error: Opening and ending tag mismatch: table and font
+</table>
+       ^
 ./test/HTML/wired.html:374: error: htmlParseEntityRef: no name
 a, sans-serif"><b><a href="/news/commentarySection/0,1292,31926,00.html">Rants 
-                                                                                ^
+                                                                              ^
 ./test/HTML/wired.html:374: error: Opening and ending tag mismatch: td and font
 Readers on Apple's G4 ... AOL's passwords ... MS vs. Linux.</font><br><br>  </t
-                                                                                ^
-./test/HTML/wired.html:374: error: Opening and ending tag mismatch: td and font
-Readers on Apple's G4 ... AOL's passwords ... MS vs. Linux.</font><br><br>  </t
-                                                                                ^
+                                                                              ^
+./test/HTML/wired.html:375: error: Opening and ending tag mismatch: tr and font
+        </tr>
+            ^
 ./test/HTML/wired.html:402: error: Opening and ending tag mismatch: a and font
 w.vignette.com/" style="text-decoration:none"><font color="#000000">Vignette</a
-                                                                                ^
+                                                                              ^
+./test/HTML/wired.html:402: error: Opening and ending tag mismatch: i and font
+gnette.com/" style="text-decoration:none"><font color="#000000">Vignette</a></i
+                                                                              ^
 ./test/HTML/wired.html:406: error: htmlParseEntityRef: expecting ';'
 ervlet/appservlet?from=/wired/sprint/&template=/security/security.html&SITE=
                                               ^
@@ -222,34 +237,40 @@
                 ^
 ./test/HTML/wired.html:406: error: Opening and ending tag mismatch: a and font
 com&BANNER=Sprint" style="text-decoration:none"><font color="#000000">Sprint</a
-                                                                                ^
+                                                                              ^
+./test/HTML/wired.html:406: error: Opening and ending tag mismatch: i and font
+BANNER=Sprint" style="text-decoration:none"><font color="#000000">Sprint</a></i
+                                                                              ^
 ./test/HTML/wired.html:406: error: End tag : expected '>'
 =Sprint" style="text-decoration:none"><font color="#000000">Sprint</a></i></fon
-                                                                                ^
+                                                                              ^
+./test/HTML/wired.html:406: error: Opening and ending tag mismatch: font and a
+" style="text-decoration:none"><font color="#000000">Sprint</a></i></font</font
+                                                                              ^
 ./test/HTML/wired.html:412: error: Opening and ending tag mismatch: td and font
 </td>
     ^
-./test/HTML/wired.html:412: error: Opening and ending tag mismatch: td and font
-</td>
-    ^
-./test/HTML/wired.html:412: error: Opening and ending tag mismatch: td and font
-</td>
-    ^
-./test/HTML/wired.html:412: error: Opening and ending tag mismatch: td and font
-</td>
-    ^
-./test/HTML/wired.html:412: error: Opening and ending tag mismatch: td and font
-</td>
-    ^
-./test/HTML/wired.html:412: error: Opening and ending tag mismatch: td and font
-</td>
-    ^
-./test/HTML/wired.html:412: error: Opening and ending tag mismatch: td and font
-</td>
-    ^
-./test/HTML/wired.html:412: error: Opening and ending tag mismatch: td and font
-</td>
+./test/HTML/wired.html:413: error: Opening and ending tag mismatch: tr and font
+</tr>
     ^
 ./test/HTML/wired.html:430: error: htmlParseEntityRef: expecting ';'
 href="http://www.lycos.com/news/flash/hitlerbunker.html?v=wn1015&lpv=1">Lycos</
                                                                     ^
+./test/HTML/wired.html:434: error: Opening and ending tag mismatch: table and font
+</table>
+       ^
+./test/HTML/wired.html:461: error: Opening and ending tag mismatch: td and font
+   </TD>
+       ^
+./test/HTML/wired.html:462: error: Opening and ending tag mismatch: tr and font
+  </TR>
+      ^
+./test/HTML/wired.html:508: error: Opening and ending tag mismatch: table and font
+</TABLE>
+       ^
+./test/HTML/wired.html:512: error: Opening and ending tag mismatch: body and font
+</body>
+      ^
+./test/HTML/wired.html:513: error: Opening and ending tag mismatch: html and font
+</html>
+      ^
diff --git a/result/HTML/wired.html.sax b/result/HTML/wired.html.sax
index b94358c..ab0c6c4 100644
--- a/result/HTML/wired.html.sax
+++ b/result/HTML/wired.html.sax
@@ -779,8 +779,6 @@
 SAX.characters(
 , 1)
 SAX.error: Opening and ending tag mismatch: td and form
-SAX.endElement(form)
-SAX.endElement(td)
 SAX.characters( 
 		, 4)
 SAX.startElement(td, valign='top', bgcolor='#99FF99')
@@ -794,12 +792,12 @@
 SAX.endElement(td)
 SAX.characters(
 	, 2)
-SAX.endElement(tr)
+SAX.error: Opening and ending tag mismatch: tr and form
 SAX.characters(    , 4)
-SAX.error: Unexpected end tag : form
+SAX.endElement(form)
 SAX.characters(
 , 1)
-SAX.endElement(table)
+SAX.error: Opening and ending tag mismatch: table and td
 SAX.endElement(td)
 SAX.characters(
   , 3)
@@ -1077,9 +1075,7 @@
 SAX.endElement(select)
 SAX.endElement(font)
 SAX.error: Opening and ending tag mismatch: td and form
-SAX.endElement(form)
-SAX.endElement(td)
-SAX.endElement(tr)
+SAX.error: Opening and ending tag mismatch: tr and form
 SAX.characters(
  , 2)
 SAX.startElement(tr, align='left', valign='top')
@@ -1141,10 +1137,10 @@
         , 9)
 SAX.endElement(tr)
 SAX.characters(  , 2)
-SAX.error: Unexpected end tag : form
+SAX.endElement(form)
 SAX.characters(
         , 9)
-SAX.endElement(table)
+SAX.error: Opening and ending tag mismatch: table and td
 SAX.characters(
 
 , 2)
@@ -1456,23 +1452,21 @@
 SAX.characters(
 , 1)
 SAX.error: Opening and ending tag mismatch: td and font
-SAX.endElement(font)
-SAX.endElement(td)
 SAX.characters(
   , 3)
-SAX.endElement(tr)
+SAX.error: Opening and ending tag mismatch: tr and font
 SAX.characters(
 
 , 2)
-SAX.endElement(table)
-SAX.ignorableWhitespace(
+SAX.error: Opening and ending tag mismatch: table and font
+SAX.characters(
 
 , 2)
 SAX.comment( end lower left side Navigation )
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
 SAX.comment( CONTENT TABLE )
-SAX.ignorableWhitespace(
+SAX.characters(
 
 , 2)
 SAX.startElement(table, border='0', width='447', cellspacing='0', cellpadding='0', bordercolor='#66FF00')
@@ -1632,13 +1626,9 @@
 SAX.endElement(br)
 SAX.characters(  , 2)
 SAX.error: Opening and ending tag mismatch: td and font
-SAX.endElement(font)
-SAX.error: Opening and ending tag mismatch: td and font
-SAX.endElement(font)
-SAX.endElement(td)
 SAX.characters(
         , 9)
-SAX.endElement(tr)
+SAX.error: Opening and ending tag mismatch: tr and font
 SAX.characters(
 , 1)
 SAX.comment( Commentary Frag End )
@@ -1894,9 +1884,7 @@
 SAX.startElement(font, color='#000000')
 SAX.characters(Vignette, 8)
 SAX.error: Opening and ending tag mismatch: a and font
-SAX.endElement(font)
-SAX.endElement(a)
-SAX.endElement(i)
+SAX.error: Opening and ending tag mismatch: i and font
 SAX.endElement(font)
 SAX.startElement(br)
 SAX.endElement(br)
@@ -1959,12 +1947,10 @@
 SAX.startElement(font, color='#000000')
 SAX.characters(Sprint, 6)
 SAX.error: Opening and ending tag mismatch: a and font
-SAX.endElement(font)
-SAX.endElement(a)
-SAX.endElement(i)
+SAX.error: Opening and ending tag mismatch: i and font
 SAX.error: End tag : expected '>'
 SAX.endElement(font)
-SAX.endElement(font)
+SAX.error: Opening and ending tag mismatch: font and a
 SAX.startElement(br)
 SAX.endElement(br)
 SAX.startElement(br)
@@ -2010,25 +1996,9 @@
 
 , 2)
 SAX.error: Opening and ending tag mismatch: td and font
-SAX.endElement(font)
-SAX.error: Opening and ending tag mismatch: td and font
-SAX.endElement(font)
-SAX.error: Opening and ending tag mismatch: td and font
-SAX.endElement(font)
-SAX.error: Opening and ending tag mismatch: td and font
-SAX.endElement(font)
-SAX.error: Opening and ending tag mismatch: td and font
-SAX.endElement(font)
-SAX.error: Opening and ending tag mismatch: td and font
-SAX.endElement(font)
-SAX.error: Opening and ending tag mismatch: td and font
-SAX.endElement(font)
-SAX.error: Opening and ending tag mismatch: td and font
-SAX.endElement(font)
-SAX.endElement(td)
 SAX.characters(
 , 1)
-SAX.endElement(tr)
+SAX.error: Opening and ending tag mismatch: tr and font
 SAX.characters(
 , 1)
 SAX.comment( start of Gen News )
@@ -2114,7 +2084,7 @@
 SAX.comment( end of Gen News )
 SAX.characters(
 , 1)
-SAX.endElement(table)
+SAX.error: Opening and ending tag mismatch: table and font
 SAX.characters(
 
 
@@ -2661,10 +2631,10 @@
 SAX.characters(
  
    , 6)
-SAX.endElement(td)
+SAX.error: Opening and ending tag mismatch: td and font
 SAX.characters(
   , 3)
-SAX.endElement(tr)
+SAX.error: Opening and ending tag mismatch: tr and font
 SAX.characters(
 
   , 4)
@@ -2831,20 +2801,57 @@
 SAX.endElement(tr)
 SAX.characters(
 , 1)
-SAX.endElement(table)
-SAX.ignorableWhitespace(
+SAX.error: Opening and ending tag mismatch: table and font
+SAX.characters(
 
 
 , 3)
 SAX.startElement(br)
 SAX.endElement(br)
-SAX.ignorableWhitespace(
+SAX.characters(
 , 1)
-SAX.endElement(body)
-SAX.ignorableWhitespace(
+SAX.error: Opening and ending tag mismatch: body and font
+SAX.characters(
 , 1)
-SAX.endElement(html)
+SAX.error: Opening and ending tag mismatch: html and font
 SAX.ignorableWhitespace(
 
 , 2)
+SAX.endElement(font)
+SAX.endElement(a)
+SAX.endElement(i)
+SAX.endElement(font)
+SAX.endElement(font)
+SAX.endElement(a)
+SAX.endElement(i)
+SAX.endElement(font)
+SAX.endElement(font)
+SAX.endElement(font)
+SAX.endElement(font)
+SAX.endElement(font)
+SAX.endElement(font)
+SAX.endElement(font)
+SAX.endElement(font)
+SAX.endElement(td)
+SAX.endElement(tr)
+SAX.endElement(font)
+SAX.endElement(font)
+SAX.endElement(td)
+SAX.endElement(tr)
+SAX.endElement(table)
+SAX.endElement(td)
+SAX.endElement(tr)
+SAX.endElement(table)
+SAX.endElement(font)
+SAX.endElement(td)
+SAX.endElement(tr)
+SAX.endElement(table)
+SAX.endElement(td)
+SAX.endElement(tr)
+SAX.endElement(table)
+SAX.endElement(td)
+SAX.endElement(tr)
+SAX.endElement(table)
+SAX.endElement(body)
+SAX.endElement(html)
 SAX.endDocument()