从 HTML 标签汤生成 .NET XmlDocument 的库

发布于 2024-07-16 15:12:29 字数 743 浏览 3 评论 0原文

我正在寻找一个 .NET 库,它可以从无效的 HTML 代码生成干净的 Xml 树,最好是 System.Xml.XmlDocument。 IE 应该在遇到这种情况时尽最大努力进行猜测、修复和替换,并生成一个假装的 XmlDocument。 图书馆也应该维护良好。 :)

我意识到这个问题太多(太多了?),我将不胜感激任何有用的线索。 Java 似乎有相当多的实现,但我宁愿不生成自己的绑定。 到目前为止,对于.NET,我已经找到 http://www.majestic12.co.uk/ items/html_parser.phphttp://users.rcn.com/ creitzel/tidy.html#dotnethttp://sourceforge.net/projects/tidyfornet。

我还没有构建或测试任何这些,但从(稀疏)文档和罕见的更新来看,它们似乎没有我正在寻找的东西。 那么你有什么建议,无论是在这些选择中,还是根据你过去的经验。

I'm looking for a .NET library that can generate a clean Xml tree, ideally System.Xml.XmlDocument, from invalid HTML code. I.E. it should make the kind of best effort guesses, repairs, and substitutions browsers do when confronted with this situation, and generate a pretend XmlDocument. The library should also be well-maintained. :)

I realize this is a lot (too much?) to ask, and I would appreciate any useful leads. There seem to be a fair number of implementations of this for Java, but I would rather not generate my own bindings. So far for .NET I have found http://www.majestic12.co.uk/projects/html_parser.php and http://users.rcn.com/creitzel/tidy.html#dotnet, and http://sourceforge.net/projects/tidyfornet .

I have not yet built or tested any of these, but from the (sparse) docs and rare updates they do not seem like they have what I'm looking for. So what recommendations do you have, either among these choices, or from your past experience.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

从来不烧饼 2024-07-23 15:12:29

HTML Agility Pack 评价很高。 它肯定会进行解析/最佳猜测等。

该模型与 XmlDocument 非常相似,包括用于查询的 SelectNodes 等。

如果您需要 xhtml 输出,则有一个 OptionOutputAsXml 标志; 我假设将其设置为 true 并调用 Save 会生成 xhtml。

The HTML Agility Pack is highly rated. It will certainly do the parsing / best guess etc.

The model is intentially similar to XmlDocument, including SelectNodes etc for querying.

If you need xhtml output, there is a OptionOutputAsXml flag; I assume that setting this to true and calling Save results in xhtml.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文