如何复制html文本选择并将其分配给一个字符串在c# [英] How to copy html text selection and assign it to a string in c#

查看:186
本文介绍了如何复制html文本选择并将其分配给一个字符串在c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.html文件只包含文本(格式不知何故)。我想知道是否有一种方法来复制所有的文本(像如果使用ctrl + A),并将其分配给字符串所以我可以然后将其导出到.txt文件?所有这些必须发生在代码隐藏(打开html,选择文本并将其分配给字符串)。

I have an .html file containing only text(formatted somehow).I am wondering if there is a way to copy all of the text(like if would do with ctrl+A) and assign it to a string So I can then export it to .txt file ? All this must happen from the code-behind(opening the html, selecting the text and assigning it to a string).

Office.Interop 我记得有一个选项复制活动窗口选择或某事,所以我想知道这是否可能和这里。

In the Microsoft.Office.Interop I remember that there was an option for copying the active window selection or something, so I was wondering if this is possible and here.

推荐答案

使用 HttpAgilityPack 。有人可以说它是夸大了,但否则明天你会问我们如何转换&代码;在文件中,第二天你会问别的。

Use HttpAgilityPack. Someone could say it's overblown, but otherwise tomorrow you'll ask us how to convert the &code; that are in the file, and the next day you'll ask something else.

这篇关于如何复制html文本选择并将其分配给一个字符串在c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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