我正在检查MSDN上的XmlNode.Attributes主题,该主题用于检查XmlNode属性是否存在给定其名称的方法.那么,没有关于如何检查项目的示例.
我有类似的东西:
//some code here...
foreach (XmlNode node in n.SelectNodes("Cities/City"))
{
//is there some method to check an attribute like
bool isCapital = node.Attributes.Exist("IsCapital");
//some code here...
}
Run Code Online (Sandbox Code Playgroud)
那么,检查每个节点中是否存在属性的最佳方法是什么?可以使用node.Attribute["IsCapital"]!=null吗?