HTML解析器和放大器;对于.NET / C#对象模型放大器、模型、对象、HTML

2023-09-04 02:30:49 作者:那时年少

我在寻找使用.NET测试或维护其内容的目的来解析HTML。 即

I'm looking to parse html using .net for the purposes of testing or asserting its content. i.e.

的HTMLDocument DOC = GetDocument(一些HTML) 列表形式= doc.Forms() 链接链接= doc.GetLinkByText(新客户)

HtmlDocument doc = GetDocument("some html") List forms = doc.Forms() Link link = doc.GetLinkByText("New Customer")

这个想法是让人们编写测试类似于C#来他们webrat怎么办(红宝石)。

the idea is to allow people to write tests in c# similar to how they do in webrat (ruby).

即。

浏览次数('\') fills_in姓名,米克 点击保存

visits('\') fills_in "Name", "mick" clicks "save"

我见过的HTML敏捷包,sgmlreader等​​,但有没有人创造了一个这样的对象模型,即一组类重新presenting HTML元素,如表单,按钮等??

I've seen the html agility pack, sgmlreader etc but has anyone created an object model for this, i.e. a set of classes representing the html elements, such as form, button etc??

干杯。

推荐答案

这里是对HTML解析好的库,对象,比如HtmlButton,HtmlInput s的未创建的,但它是一个很好的点来启动和自己创建它们,如果你不希望使用HTML DOM

Here is good library for html parsing, objects like HtmlButton , HtmlInput s are not created but it is a good point to start and to create them yourself if you don't want to use HTML DOM