C#:HtmlDocument对象没有构造函数? [英] C#: HtmlDocument object has no constructor?
问题描述
有没有其他来源获得一个实例化的HtmlDocument,我可以从一个字符串转储HTML?
或者,当使用InnerHtml / OuterHtml与img标签和tr元素时,是否有办法覆盖HtmlElement的烦人习惯?
编辑:我是指System.Windows.Forms.HtmlDocument。我很抱歉,我仍然是C#和.Net的新手,对COM和其他一些其他的东西很少了解。
它没有构造函数,因为它只是一个非托管对象的包装类。
参考: http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.aspx
HtmlDocument为Internet Explorer的
文档对象提供一个受管理的
包装,也称为
HTML文档对象模型(DOM)。您
通过
WebBrowser控件的Document属性获取HtmlDocument
的实例。
根据您想要的内容,您可能需要查看 SGMLReader 或最新版本,日期社区版本。
What's up with that? It seems the only way to get an working HtmlDocument object is copying the Document property of an mshtml/webbrowser control. But spawning that is sloooooooooooow. I'd like to avoid writing my own HTML parser and HtmlAgilityPack is copyleft.
Are there other sources of getting an instantiated HtmlDocument that I can dump HTML from a string into?
Or, is there a way to override HtmlElement's annoying habit of throwing a fit when using InnerHtml/OuterHtml with img tags and tr elements?
Edit: I'm referring to System.Windows.Forms.HtmlDocument. My apologies, I'm still new to C# and .Net and know very little about COM and some of the other things this topic brings up.
It has no constructor because it's just a wrapper class around an unmanaged object.
Reference: http://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument.aspx
HtmlDocument provides a managed wrapper around Internet Explorer's document object, also known as the HTML Document Object Model (DOM). You obtain an instance of HtmlDocument through the Document property of the WebBrowser control.
Depending on what you want it for, you may want to look at SGMLReader or the up-to-date community version.
这篇关于C#:HtmlDocument对象没有构造函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!