简体   繁体   English

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

[英]How to read copied html text from clipboard with its html tags?

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

Is it possible to read it from .NET application? 是否可以从.NET应用程序中读取它?

thanks 谢谢

The Clipboard.GetText method will retrieve HTML content from the clipboard: Clipboard.GetText方法将从Clipboard.GetText检索HTML内容:

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

You can check if the clipboard contains HTML with the Clipboard.ContainsText method. 您可以使用Clipboard.ContainsText方法检查剪贴板是否包含HTML。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM