c# - 如何将 html 文档保存到字符串中?

标签 c# data-conversion dom

 HtmlDocument doc = new HtmlDocument();
    doc.Load(yourhtml);
    doc.Save(Console.Out);

如何将其保存为字符串而不是 Console.Out

最佳答案

string s = doc.DocumentNode.OuterHtml;

var sw = new StringWriter();
doc.Save(sw);
var s = sw.ToString();

关于c# - 如何将 html 文档保存到字符串中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18399694/

相关文章:

c# - 正确地将字节从 C++ 转换为 delphi AnsiString

PHP DOM textContent 与 nodeValue?

java - 时间转换问题

c - 快速整数到十进制转换

c# - 如何使用线程启动带参数的方法

c# - 找到两个多边形之间最短笛卡尔距离的最快方法是什么

javascript - 让每个按钮操作其上方的内容

php - 检查用户是否在兼容模式下使用 IE

c# - 将 Visual Studio 中输出目录的文件名 <AssemblyName.exe.config> 更改为 <App.Config>

c# - 什么是 C# 中 C++ vector 的良好替代品?