0
我有一个DIV可以有一个attribut edth_type
,我希望能够通过if
比较它的价值。如何按节点排序AgilityPack
我已经看到了其他职位一些人使用
if (string.Compare(node.Attributes["edth_type"].Value, "contenu", StringComparison.InvariantCultureIgnoreCase) == 0)
{
node.Remove();
}
但事实是,我需要能够做更多的事情,如:
if(node.Attributes["edth_type"] != contenu)
{
node.remove
}
我如何能做到这一点,我已阅读msdn文档有关string.Compare
,但不理解它,我想知道,因为我使用HtmlAgilityPack,如果有一种方法可以做到这一点。
有人能解释一下string.Compare是可能性(-1,0,1)还是知道一个更好的方法来测试一个attribute在HtmlAgilityPack中?
安装程序:ASP.NET 4.0,代码位于C#服务器端。
比较对于排序(因此返回值) - 您可能希望使用'string.Equals(node.Attributes [“edth_type”] .value,“contenu”,StringComparison.InvariantCultureIgnoreCase)'代替 – stuartd
@stuartd在我使用Equals的情况下,它会返回0或1代表“=”或“! =“? – Slayner
Equals返回一个布尔值,所以'true'或'false'是可能的值 – stuartd