1 buah xml pada model.xml
<?xml versi="1.0" pengkodean="utf-8" ?>
<DrRoot>
<NamaSitus>xml作示例</NamaSitus>
<SiteUrl>www.abc.com.cn</SiteUrl>
<SiteDescript>.net开源论坛</SiteDescript>
<SiteKeyWord>xml aplikasi</SiteKeyWord>
<FileType>gif|jpg|rar</FileType>
<Ukuran File>1024</Ukuran File>
<Filter>skrip|iframe</Filter>
<FilterEvent>onload|onmouseover</FilterEvent>
<BadWords>admin|webmaster|drbbs</BadWords>
<DisallowIP>0.0.0.0</DisallowIP>
<IsCloseReg>Salah</IsCloseReg>
<IsCloseBBS>Salah</IsCloseBBS>
<Pascabayar>5</Pascabayar>
<BalasBayar>2</BalasBayar>
<GoodPay>10</GoodPay>
<DelPost>5</DelPost>
<DelReply>2</DelReply>
<CancleGood>10</CancleGood>
</DrRoot>
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