/*
在项目里引用了mshtml.dll,并且引用命名空间:using mshtml;
首先,参数html就是html文本内容(里面有markup标记和显示文本等等)
其次,getHtmlDisplayContent这个函数就是获取html里浏览器上可看到的内容,即从源码中取出显示文本。
最后,traverseNodes是个人写的一个遍历各个节点的一个小小递归程序,没考虑效率什么的,只是想知道怎么使用IHtmlDocument2和IHtmlDocument3接口
Note:当html文档不规范时,比如在
*/
private static string getHtmlDisplayContent(string html)
{
string cont = "";
mshtml.HTMLDocumentClass oc = new mshtml.HTMLDocumentClass();
mshtml.IHTMLDocument2 doc2 = oc;
doc2.write(html);
mshtml.IHTMLDocument3 HTMLDocument = (mshtml.IHTMLDocument3)doc2;
traverseNodes(HTMLDocument.documentElement, ref cont);
//mshtml.IHTMLTitleElement title = (mshtml.IHTMLTitleElement)doc2.title;
/* cont += doc2.title.ToString();
mshtml.IHTMLBodyElemen