1 Datei xml oder model.xml
2 主要方法
public string ReadValue(string key)
{
XmlDocument xd=new XmlDocument();
xd.Load(Server.MapPath("model.xml"));
XmlNodeList xnl = xd.GetElementsByTagName(key);
if(xnl.Count==0)
zurückkehren "";
anders
{
XmlNode mNode=xnl[0];
return mNode.InnerText;
}
}
public void UpdateValue(string nKey,string nValue)
{
if(ReadValue(nKey)!="")
{
XmlDocument xmlDoc=new XmlDocument();
xmlDoc.Load(Server.MapPath("model.xml"));
XmlNodeList elemList = xmlDoc.GetElementsByTagName(nKey);
XmlNode mNode=elemList[0];
mNode.InnerText=nValue;
XmlTextWriter xw = new XmlTextWriter(new StreamWriter(Server.MapPath("model.xml")));
xw.Formatting = Formatting.Indented;
xmlDoc.WriteTo(xw);
xw.Close();
}
}
http://www.cnblogs.com/aqiang/archive/2006/10/24/538750.html