1 buah xml pada model.xml
2
string publik ReadValue(kunci string)
{
XmlDocument xd=XmlDocument baru();
xd.Load(Server.MapPath("model.xml"));
XmlNodeList xnl = xd.GetElementsByTagName(kunci);
if(xnl.Hitungan==0)
kembali "";
kalau tidak
{
XmlNode mNode=xnl[0];
kembalikan mNode.InnerText;
}
}
kekosongan publik UpdateValue(string nKey,string nValue)
{
jika(NilaiBaca(nKey)!="")
{
XmlDocument xmlDoc=XmlDocument baru();
xmlDoc.Load(Server.MapPath("model.xml"));
XmlNodeList elemList = xmlDoc.GetElementsByTagName(nKey);
XmlNode mNode=elemList[0];
mNode.InnerText=nNilai;
XmlTextWriter xw = XmlTextWriter baru(StreamWriter baru(Server.MapPath("model.xml")));
xw.Formatting = Memformat.Indentasi;
xmlDoc.WriteTo(xw);
xw.Tutup();
}
}
http://www.cnblogs.com/aqiang/archive/2006/10/24/538750.html