推薦:ASP.NET筆記之廣告控件的使用方法
本篇文章小編為大家介紹,ASP.NET筆記之廣告控件的使用方法,需要的朋友參考下
xml 文件內容:復制代碼 代碼如下:www.CuoXIn.com
<?xml version="1.0" encoding="utf-8"?>
<subtitles>
<info>
<content>最新通告:五一放假七天!請各教員悉知</content>
<speed>4</speed>
<color>red</color>
</info>
</subtitles>
C#代碼:復制代碼 代碼如下:www.CuoXIn.com
XmlDocument xml = new XmlDocument();
xml.Load(context.Server.MapPath("~/js/XMLFile.xml"));
XmlNode xn = xml.DocumentElement;
foreach (XmlNode node in xn.ChildNodes)
{
if (node.Name == "info")
{
node["content"].InnerText = content;
node["speed"].InnerText = speed;
node["color"].InnerText = color;
}
}
xml.Save(context.Server.MapPath("~/js/XMLFile.xml"));
另外兩種辦法:
修改xml字符串的某個節點的屬性值,如下:復制代碼 代碼如下:www.CuoXIn.com
XmlDocument doc = new XmlDocument();
doc.LoadXml("<fsdlconfig userName=/"ss/" password=/"134/"/>");
XmlAttribute att =(XmlAttribute)doc.SelectSingleNode("/fsdlconfig/@userName");
Console.WriteLine(att.Value);
att.Value = "test";
string str = doc.OuterXml;
節點userName的值由原來的"ss",變成了"test",然后用doc.OuterXml保存修改后的xml為字符串。
另一種方式:復制代碼 代碼如下:www.CuoXIn.com
XmlDocument doc = new XmlDocument();
doc.LoadXml("<fsdlconfig userName=/"ss/" password=/"134/"/>");
XmlElement att = (XmlElement)doc.FirstChild;
att.SetAttribute("userName","test");
string str = doc.OuterXml;
分享:ASP.NET筆記之Calender的使用說明
在Calender中,所有可選擇的符號會顯示下劃線,這是因為它們在瀏覽器都會呈現為鏈接。如果讓用戶可以選擇某天、月、周,必須設置SelectionMode屬性