Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何解析 HTML 以找到带有特定or or的锚 ( <a />) 元素?idclasstitle
<a />
id
class
title
最终,我想找到href属性的值。
href
这是一个例子
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(somehtmlstring); string value = doc.DocumentNode.Descendants("a") .First(n => n.Attributes["class"].Value == "someclass") .Attributes["href"] .Value;