如何从剪贴板读取复制的 html 文本及其 html 标签?

发布于 2024-08-09 10:25:51 字数 99 浏览 2 评论 0原文

当用户从网页中选择并复制文本时,我需要获取包含所有 html 标签的文本,以便我可以选择一些特定的属性等。

是否可以从 .NET 应用程序读取它?

谢谢

When a user selects and copies a text from a web page, I need to get that text with all the html tags included so that I can select some specific attributes etc.

Is it possible to read it from .NET application?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的奇迹 2024-08-16 10:25:51

Clipboard.GetText 方法将检索剪贴板中的 HTML 内容:

var htmlData = System.Windows.Clipboard.GetText(System.Windows.TextDataFormat.Html);

您可以使用 Clipboard.ContainsText 方法。

The Clipboard.GetText method will retrieve HTML content from the clipboard:

var htmlData = System.Windows.Clipboard.GetText(System.Windows.TextDataFormat.Html);

You can check if the clipboard contains HTML with the Clipboard.ContainsText method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文