是否有一个XmlReader相当于HTML中的净? [英] Is there an XmlReader equivalent for HTML in .Net?

查看:156
本文介绍了是否有一个XmlReader相当于HTML中的净?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 HtmlAgilityPack 在过去的净解析HTML,但我不吨像,它仅使用一个DOM模型的事实。

I've used HtmlAgilityPack in the past to parse HTML in .Net but I don't like the fact that it only uses a DOM model.

在大型文档和/或那些与嵌套的沉重水平有可能打栈溢出或内存不足异常。此外,在一般的基于DOM解析模型使用显著的内存比基于流媒体的方式,通常是因为要消耗HTML的过程可能只需要几个要素可用的时间。

On large documents and/or those with heavy levels of nesting it is possible to hit stack overflow or out of memory exceptions. Also in general a DOM based parsing model uses significantly more memory than a streaming based approach, typically because the process that wants to consume the HTML may only need a few elements to be available at a time.

有谁知道对于.NET一个体面的HTML解析器,可以让你在类似的XmlReader 类的方式解析HTML的?即在一个只进的流媒体的方式

Does anyone know of a decent HTML parser for .Net that allows you to parse HTML in a manner similar to the XmlReader class? i.e. in a forward only streaming manner

推荐答案

我通常使用SgmlReader这个: https://github.com/ MindTouch的/ SGMLReader

I usually use SgmlReader for this: https://github.com/MindTouch/SGMLReader

像其他人所说的,也有在HTML不遵循XML的同时良好的规则问题,所以它本质上是很难分析,但SgmlReader通常做了pretty的好工作。

Like others have said, there are issues in that HTML doesn't follow the same well-formed rules of XML, so it is inherently difficult to parse, but SgmlReader usually does a pretty good job.

这篇关于是否有一个XmlReader相当于HTML中的净?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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