如何在ASP.Net中使用HtmlAgilityPack获取div类名 [英] How to get div class name using HtmlAgilityPack in ASP.Net
本文介绍了如何在ASP.Net中使用HtmlAgilityPack获取div类名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
就像我写的那样
HtmlNode.Id然后我得到Id of element div。所以,如果我必须获得div元素的类名
我必须写的...
需要帮助
谢谢..
Just Like if i write
HtmlNode.Id then i am getting Id Of element div. So if i have to get class name of the div element
what i have to write ...
need assistence
thank you..
推荐答案
// Where node is a HtmlNode instance
string[] cssClasses = node.Attributes["class"] != null
? node.Attributes["class"].Value.Split(new[] {" "}, StringSplitOptions.RemoveEmptyEntries)
: new string[0];
foreach(string cssClass in cssClasses)
{
// Do whatever you need to do with the CSS class
}
这篇关于如何在ASP.Net中使用HtmlAgilityPack获取div类名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文