使用C#以编程方式删除HtmlElement对象 [英] Removing HtmlElement objects programmatically using C#

查看:167
本文介绍了使用C#以编程方式删除HtmlElement对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WebBrowser 控件中,如何删除 HtmlElement 对象?在 HtmlElement 类中没有方法来完成此任务。作为解决方法,我可以创建一个虚拟 HtmlElement (不插入到 HtmlDocument ),我然后插入(通过 AppendChild )要删除的 HtmlElement 对象。这感觉就像一个黑客有更好的方法吗?

In a WebBrowser control, how do I remove HtmlElement objects? There are no methods in the HtmlElement class to accomplish this. As a workaround, I can create a "dummy" HtmlElement (without inserting it into the HtmlDocument), into which I then insert (via AppendChild) the HtmlElement objects to be removed. This feels like a hack. Is there a better way to do this?

P.S。我想保留内存中的 HtmlElement 以供稍后使用,而不是简单地将其删除(这是设置其父级的 innerHtml 一个空字符串会做)

P.S. I want to retain the HtmlElement in memory to be used later, not simply destroy it (which is what setting its parent's innerHtml to an empty string would do)

推荐答案

查看这个WebControl遗产,具有很多功能: http://www.codeproject.com/KB/miscctrl/csEXWB.aspx

Look at this WebControl Heritance, with loads of feature: http://www.codeproject.com/KB/miscctrl/csEXWB.aspx

您可以通过ID为del元素添加删除方法。

You could add a remove method to del element by id.

希望这有助于

这篇关于使用C#以编程方式删除HtmlElement对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆