用程序从web浏览器控件中删除html元素

本文关键字:删除 html 元素 控件 浏览器 程序 web | 更新日期: 2023-09-27 17:59:48

我在谷歌上搜索,发现了几行代码

using Microsoft.mshtml;
....
{
...
    // To Remove     
    HTMLDocumentClass htmldoc = wbCtrl.Document.DomDocument as HTMLDocumentClass;
    IHTMLDOMNode node = htmldoc.getElementById("xBar") as IHTMLDOMNode;
    node.parentNode.removeChild(node);
...
}

mshtml引用出现错误,但我从以下路径添加库C:''Program Files''Microsoft.NET''Primary Interop Assemblies并添加名为Microsoft.mshtml.dll的dll

但还是犯了错误。因此,请帮助我添加我可以使用的上述代码。我正在运行我的应用程序VS2010 IDE。

用程序从web浏览器控件中删除html元素

转发您最近问题的旧答案,如果适用:

//in class def
private bool firstTime;
//in method
bool firstTimeLcl = firstTime
firstTime = false;
if (firstTimeLcl)
{
//write header
} 
else
{
String.Replace(/*closing tags*/, "");
}
//write everything within body
//write closing tags