如何使用C#访问特定的HTML元素? [英] How do I access a specific HTML element using C#?
问题描述
例如,让我说我需要访问:/ html / body / div / div [3] / div / table [0] / div / ul / li [12] / a /。
我如何去做这个?
HTML格式良好,您可以使用 XmlDocument
此外,Maxim提到, HTML Agility Pack < a>可以做你所需要的。
以下是4guysfromrolla的最新文章,使用HTML Agility Pack解析HTML
I have a string containing HTML and I need to be able to access a specific element to get the text from it (the element has no id or class or name so regex is out of the question).
For example, lets say I needed to access: "/html/body/div/div[3]/div/table[0]/div/ul/li[12]/a/".
How could I go about doing this?
If the HTML is well formatted, you can parse the HTML with an XmlDocument
Also as Maxim mentioned, the HTML Agility Pack can probably do what you need.
Here's a recent article from 4guysfromrolla on parsing HTML with the HTML Agility Pack
这篇关于如何使用C#访问特定的HTML元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!