//xmlFile是xml文件,nodeName是节点名,attributeName是节点的属性名,因为节点名是可以重复的,所以用list存放返回值
public List<string> GetAttribute(string xmlFile, string nodeName, string attributeName)
{
List<string> retList = new List<string>();
XmlDocument xx = new XmlDocument();
xx.Load(xmlFile);
XmlNodeList xxList = xx.GetElementsByTagName(nodeName);
foreach (XmlNode xxNode in xxList)
{
retList.Add(xxNode.Attributes[attributeName].Value);
}
return retList;
}
温馨提示:内容为网友见解,仅供参考