您的位置:首页 > 产品设计 > UI/UE

获取XML字符串中Key对应的Value

2009-09-09 14:46 465 查看
/// <summary>
/// 获取XML字符串中Key对应的Value
/// </summary>
/// <param name="xmlContent"></param>
/// <param name="xmlKey"></param>
/// <returns></returns>
public static string GetXmlValue(string xmlContent, string xmlKey)
{
string xmlValue = "";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(xmlContent);
XmlNode xnode = xmlDoc.DocumentElement;
foreach (XmlNode node in xnode.ChildNodes)
{
if (node.Attributes[0].Value == xmlKey)
{
xmlValue = node.InnerText;
}
}
return xmlValue;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: