日期:2014-05-18  浏览次数:20618 次

!!请教一个并不是太难的问题~~请各位高手解答~马上结帐~~概不拖欠~~~
一个winform程序   ,里面有个webBrowser   ,   webBrowser读取的是一个HTML文件,我想要把webBrowser里面自己想要的东西解析出来,用了mshtml    
    下面是错误的地方:
  mshtml.IHTMLDocument2   doc   =   (mshtml.IHTMLDocument2)webBrowser1.Document;
                                                //取得网页中包含的所有文本内容doc.body.innerText    

                        mshtml.IHTMLElementCollection   collection   =   doc.all;

下面是报的错:
错误 129 无法将类型“System.Windows.Forms.HtmlDocument”转换为“mshtml.IHTMLDocument2”

我一前在03用可以,现在在05里不成了,不知道是什么原因
请各位高手解答,~~分不够再加~~
谢谢

------解决方案--------------------
没接触过,帮顶
------解决方案--------------------
学习
------解决方案--------------------
up
------解决方案--------------------
UP
------解决方案--------------------
MARK
------解决方案--------------------
(mshtml.IHTMLDocument2)webBrowser1.Document是这句转换出错了,不能强制转换。可能是05的转换方法不同吧~我也没接触过。
------解决方案--------------------
刚查了一下资料。lz试试这个
mshtml.IHTMLDocument2 doc = WebBrowser1.Document.DomDocument
应该能用在05里面

------解决方案--------------------
mshtml.IHTMLElementCollection collection = doc.all as IHTMLDocument2;
要转换