这个xml文件我怎么解析呢?

2025-04-15 14:44:07
推荐回答(2个)
回答1:

这个是我写的个操作xml的方法,你看看吧,这个是设置的,改下就可以了

///


/// 设置 AppSetting 配置值
///

/// 配置键
/// 配置值
public static void SetAppConfig(string strKey, string strValue)
{
string filePath = System.Web.HttpContext.Current.Server.MapPath("/Config/SiteSettings.config");
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(filePath);
XmlNode xmlNode = xmldoc.SelectSingleNode("/appSettings/add[@key='" + strKey + "']");
XmlElement element = xmlNode as XmlElement;
element.Attributes["value"].Value = strValue;
xmldoc.Save(filePath);
}

回答2:

XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(XMLFileName);
XmlNodeList xnl = xmldoc.GetElementsByTagName("title");
foreach (XmlNode xn in xnl)
{
label1.Text = xn.InnerText.ToString();
}