資源簡(jiǎn)介
.net資源 XML增刪改查(不用數(shù)據(jù)庫,直接用xml代替,速度和效率很快)XML增刪改查(不用數(shù)據(jù)庫,直接用xml代替,速度和效率很快)XML增刪改查(不用數(shù)據(jù)庫,直接用xml代替,速度和效率很快)XML增刪改查(不用數(shù)據(jù)庫,直接用xml代替,速度和效率很快)XML增刪改查(不用數(shù)據(jù)庫,直接用xml代替,速度和效率很快)XML增刪改查(不用數(shù)據(jù)庫,直接用xml代替,速度和效率很快)XML增刪改查 (不用數(shù)據(jù)庫,直接用xml代替,速度和效率很快)

代碼片段和文件信息
using?System;
using?System.Data;
using?System.Configuration;
using?System.Collections;
using?System.Web;
using?System.Web.Security;
using?System.Web.UI;
using?System.Web.UI.WebControls;
using?System.Web.UI.WebControls.WebParts;
using?System.Web.UI.HtmlControls;
using?System.xml;
public?partial?class?AddlinkMan?:?System.Web.UI.Page
{
????protected?void?Page_Load(object?sender?EventArgs?e)
????{
????}
????protected?void?btnSave_Click(object?sender?EventArgs?e)
????{
????????xmlDocument?xmlDoc?=?new?xmlDocument();
????????string?path?=?Server.MapPath(@“~/App_Data/phone.xml“);
????????xmlDoc.Load(path);?//加載xml文檔
????????xmlNode?root?=?xmlDoc.SelectSingleNode(“PhoneBook“);//查找第一個(gè)匹配的xmlNode
????????xmlNodeList?nodeList?=?root.SelectNodes(“l(fā)inkMan“);
????????foreach?(xmlNode?node?in?nodeList)
????????{
????????????if?(node.SelectSingleNode(“Name“).InnerText.Equals(txtName.Text.Trim()))
????????????{
????????????????Page.Clientscript.RegisterStartupscript(this.GetType()?“showMessage“?“alert(‘該聯(lián)系人已經(jīng)存在!‘);“?true);
????????????????return;
????????????}
????????}
????????xmlElement?linkMan?=?xmlDoc.CreateElement(“l(fā)inkMan“);//創(chuàng)建linkMan元素
????????xmlElement?nameElement?=?xmlDoc.CreateElement(“Name“);?//創(chuàng)建“Name“元素
????????nameElement.InnerText?=?txtName.Text;//設(shè)置元素的文本內(nèi)容
????????linkMan.AppendChild(nameElement);//將該節(jié)點(diǎn)添加至“l(fā)inkMan“元素末尾
????????xmlElement?cityElement?=?xmlDoc.CreateElement(“City“);?//創(chuàng)建“City“元素
????????cityElement.InnerText?=?txtCity.Text;//設(shè)置元素的文本內(nèi)容
????????linkMan.AppendChild(cityElement);//將該節(jié)點(diǎn)添加至“l(fā)inkMan“元素末尾
????????xmlElement?phoneElement?=?xmlDoc.CreateElement(“Phone“);?//創(chuàng)建“Phone“元素
????????phoneElement.InnerText?=?txtPhone.Text;//設(shè)置元素的文本內(nèi)容
????????linkMan.AppendChild(phoneElement);//將該節(jié)點(diǎn)添加至“l(fā)inkMan“元素末尾
????????xmlElement?emailElement?=?xmlDoc.CreateElement(“Email“);?//創(chuàng)建“Email“元素
????????emailElement.InnerText?=?txtEmail.Text;//設(shè)置元素的文本內(nèi)容
????????linkMan.AppendChild(emailElement);//將該節(jié)點(diǎn)添加至“l(fā)inkMan“元素末尾
????????xmlElement?birthElement?=?xmlDoc.CreateElement(“BirthDate“);?//創(chuàng)建“BirthDate“元素
????????birthElement.InnerText?=?txtBirth.Text;//設(shè)置元素的文本內(nèi)容
????????linkMan.AppendChild(birthElement);//將該節(jié)點(diǎn)添加至“l(fā)inkMan“元素末尾
????????root.AppendChild(linkMan);//把“l(fā)inkMan”元素添加至“PhoneBook”元素末尾
????????xmlDoc.Save(path);
????}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????2943??2009-07-09?17:21??xm
?????文件???????2654??2009-07-09?17:05??xm
?????文件???????1009??2009-07-09?16:08??xm
?????文件???????1247??2010-10-12?10:07??xm
?????文件???????2985??2009-09-26?16:38??xm
?????文件???????2647??2009-09-26?16:43??xm
?????文件???????1009??2009-07-09?16:08??xm
?????文件????????772??2009-09-26?16:39??xm
?????文件???????4506??2009-09-26?16:45??xm
?????文件???????3299??2009-09-26?16:18??xm
?????文件???????1546??2009-09-26?16:39??xm
?????文件???????4506??2009-07-09?17:19??xm
?????文件???????3283??2009-07-09?17:18??xm
?????目錄??????????0??2009-08-03?12:47??xm
?????目錄??????????0??2009-09-26?16:04??xm
?????目錄??????????0??2009-08-03?12:47??xm
?????目錄??????????0??2009-08-03?12:47??xm
?????目錄??????????0??2009-09-26?16:45??xm
?????目錄??????????0??2010-10-12?11:48??xm
?????目錄??????????0??2009-09-23?16:59??xm
?????文件???????1530??2010-10-12?11:48??xm
????..A..H.??????7168??2010-10-12?11:48??xm
-----------?---------??----------?-----??----
????????????????41104????????????????????22
評(píng)論
共有 條評(píng)論