我的程序非常简单, 就是从文件中读取一段HTML源代码, 再创建一个WebBrowser, 将代码放到其中, 用IHTMLXXX来进行分析, 但分析总是出错, 真是没有办法活了. 
1 建立一个文件E:\\test.txt,其中放入HTML代码,如下: 
<TR>
<TD class=folder><A title=新窗口打开 href="thread-1285657-1-1.html" target=_blank><IMG src="images/default/folder_new.gif"></A></TD>
<TD class=icon>&nbsp; </TD>
<TH class=new><LABEL><IMG alt="" src="images/default/agree.gif"> &nbsp;</LABEL> <EM>[<A href="forumdisplay.php?fid=23&amp;filter=type&amp;typeid=14">飞狐</A>]</EM> <SPAN id="thread_1285657 "><SPAN class=chcj2><A href="thread-1285657-1-1.html">最完整的阳光普照解盘原码</A></SPAN></SPAN> <IMG class=attach alt=附件 src="images/attachicons/common.gif"> <A class=new href="redirect.php?tid=1285657&amp;goto=newpost#newpost">New</A> </TH>
<TD class=author><CITE><A href="space.php?action=viewpro&amp;uid=426279">寒松</A> </CITE><EM>2008-11-29</EM> </TD>
<TD class=nums><STRONG>23</STRONG> / <EM>568</EM></TD>
<TD class=lastpost><EM><A href="redirect.php?tid=1285657&amp;goto=lastpost#lastpost">2008-11-30 08:50</A></EM> <CITE>by <A href="space.php?action=viewpro&amp;username=emulous">emulous</A></CITE> </TD></TR>解释下,就是一个TR,其中包含5个TD,一个TH。就这么多了。 2、创建一个Visual C#,Windows应用程序。在Form_Load中加入如下代码: 
            StreamReader sr = new StreamReader("E:\\test.txt", Encoding.GetEncoding("gb2312"));
            String str = sr.ReadToEnd();
            sr.Close();            WebBrowser wb = new WebBrowser();
            wb.Navigate("about:blank");
            while (wb.ReadyState != WebBrowserReadyState.Complete)
                Application.DoEvents();
            mshtml.IHTMLDocument2 HD2 = (mshtml.IHTMLDocument2)wb.Document.DomDocument;
            HD2.write("<html><body>" + str + "</body></html>");            mshtml.IHTMLDocument3 hd3 = (mshtml.IHTMLDocument3)wb.Document.DomDocument;            mshtml.IHTMLElementCollection hec = hd3.getElementsByTagName("TD");
            mshtml.IHTMLElement he = (mshtml.IHTMLElement)hec.item(0, 0);代码也非常简单,打开文件,读入HTML源代码。创建WebBrowser,得到IHTMLDocument2并
用write写入HTML源代码。再得到IHTMLDocument3,并且得到标签名为"TD"的所有元素的
集合。通过设置断点可以看变量的内容:HD3中的documentElement中的outerHTML内容都是正
确的(也就是说write写入的内容都是正确的),但是查看IHTMLElement he的outerHTML, 
outText就是错误了,就是没有得到 <TD...>... </TD>这样成对标签的内容,只是得到了 
<TD...>这个开始标签,后面的部分都没有得到。 我是百思不得其解啊,这日子没有法过了,遇到这样的软件包开发公司,日子真是没有办法过了
呀,呜呜呜呜。