您的位置:首页 > 其它

取任意xml节点中某个属性值的方法

2015-05-26 16:51 176 查看

public string GetXmlNodeValue(string strXml,string strNodeName,string strValueName)

{

try

{

System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();

xmlDoc.LoadXml(strXml);

System.Xml.XmlNode xNode = xmlDoc.SelectSingleNode("//" + strNodeName + "");

string strValue = xNode.Attributes[strValueName].Value;

return strValue;

}

catch (Exception ex)

{

return ex.Message;

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: