在 C# 中解析 html 的最佳方法是什么? [英] What is the best way to parse html in C#?

查看:32
本文介绍了在 C# 中解析 html 的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种库/方法来解析具有比通用 xml 解析库更多的 html 特定功能的 html 文件.

解决方案

Html Agility Pack<块引用>

这是一个敏捷的 HTML 解析器,它构建了一个读/写 DOM 并支持普通的 XPATH 或 XSLT(你实际上不必了解 XPATH 或 XSLT 来使用它,别担心......).它是一个 .NET 代码库,允许您解析网络之外"的代码.HTML 文件.解析器对现实世界"非常宽容.格式错误的 HTML.对象模型与 System.Xml 的建议非常相似,但适用于 HTML 文档(或流).

I'm looking for a library/method to parse an html file with more html specific features than generic xml parsing libraries.

解决方案

Html Agility Pack

This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).

这篇关于在 C# 中解析 html 的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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