我正在为.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”标签的完整页面,这是可能的吗?
我主要想验证一个开始和结束标签等,并删除标签没有匹配的开放,任何其他伟大的工具将是很好的。
发布于 2014-03-27 20:25:03
我使用以下命令找到了这个问题的答案:
doc.OutputBodyOnly = AutoBool.Yes;但在结果中,我得到的是gibrish chars而不是UTF-8 (我使用希伯来语chars),并发现它是一个3年前的开放bug……https://github.com/markbeaton/TidyManaged/issues/2这并没有解决问题: doc.InputCharacterEncoding = TidyManaged.EncodingType.Utf8;doc.OutputCharacterEncoding = TidyManaged.EncodingType.Utf8;
@Oscar我会查看你的推荐谢谢
发布于 2014-03-27 18:34:02
我过去在Tidy .Net上取得了很好的成绩。
http://sourceforge.net/projects/tidynet/
https://stackoverflow.com/questions/22684772
复制相似问题