且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查XML中是否存在特定属性?

更新时间:2021-07-14 06:50:27

您实际上可以直接索引到Attributes集合中(如果使用的是C#而不是VB):

You can actually index directly into the Attributes collection (if you are using C# not VB):

foreach (XmlNode xNode in nodeListName)
{
  XmlNode parent = xNode.ParentNode;
  if (parent.Attributes != null
     && parent.Attributes["split"] != null)
  {
     parentSplit = parent.Attributes["split"].Value;
  }
}