我在.net 中为 HtmlTidy 使用这个库包装器
https://github.com/markbeaton/TidyManaged
它有一个简单的例子:
using System;
using TidyManaged;
public class Test
{
public static void Main(string[] args)
{
using (Document doc = Document.FromString("<hTml><title>test</tootle> <body>asd</body>"))
{
doc.ShowWarnings = false;
doc.Quiet = true;
doc.OutputXhtml = true;
doc.CleanAndRepair();
string parsed = doc.Save();
Console.WriteLine(parsed);
}
}
}
我想将库用于一段 HTML 而不是带有“html”和“body”标签的完整页面,这可能吗?
我基本上想验证一个开始和结束标签等,并删除没有匹配的标签,任何其他伟大的工具都会很好。