XML常用操作之一
2007-10-23 13:46
330 查看
using System;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Configuration;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.Security;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls.WebParts;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.HtmlControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
public partial class _Default : System.Web.UI.Page
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Page_Load(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//读取数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button1_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (ds.Tables.Count > 0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataSource = ds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//过滤数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button2_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXmlSchema(Server.MapPath("book.xsd"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataView dv = new DataView(ds.Tables[0]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dv.Sort = "price desc";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//dv.RowFilter = "title = 'database设计'";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataSource = dv;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//添加记录
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button3_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXmlSchema(Server.MapPath("book.xsd"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataTable dt = ds.Tables[0];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataRow dr = dt.NewRow();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dr[0] = "1";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dr[1] ="2";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dr[2] = "3";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dt.Rows.Add(dr);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// ds.Tables.Add(dt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.WriteXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataSource = ds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//更新数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button4_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXmlSchema(Server.MapPath("book.xsd"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (ds.Tables[0].Rows[i]["title"].ToString().Trim() == "asp.net")
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.Tables[0].Rows[i][j] = j;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.AcceptChanges();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.WriteXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataSource = ds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button5_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.del(10);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//删除记录
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void del(int strid)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXmlSchema(Server.MapPath("book.xsd"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.Tables[0].Rows[strid].Delete();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.AcceptChanges();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.WriteXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataSource = ds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Data;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Configuration;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.Security;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.WebControls.WebParts;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
using System.Web.UI.HtmlControls;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
public partial class _Default : System.Web.UI.Page
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Page_Load(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//读取数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button1_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (ds.Tables.Count > 0)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataSource = ds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//过滤数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button2_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXmlSchema(Server.MapPath("book.xsd"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataView dv = new DataView(ds.Tables[0]);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dv.Sort = "price desc";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//dv.RowFilter = "title = 'database设计'";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataSource = dv;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//添加记录
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button3_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXmlSchema(Server.MapPath("book.xsd"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataTable dt = ds.Tables[0];
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataRow dr = dt.NewRow();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dr[0] = "1";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dr[1] ="2";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dr[2] = "3";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dt.Rows.Add(dr);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// ds.Tables.Add(dt);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.WriteXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataSource = ds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//更新数据
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button4_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXmlSchema(Server.MapPath("book.xsd"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (ds.Tables[0].Rows[i]["title"].ToString().Trim() == "asp.net")
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.Tables[0].Rows[i][j] = j;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.AcceptChanges();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.WriteXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataSource = ds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
protected void Button5_Click(object sender, EventArgs e)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.del(10);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
//删除记录
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
private void del(int strid)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DataSet ds = new DataSet();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.ReadXmlSchema(Server.MapPath("book.xsd"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.Tables[0].Rows[strid].Delete();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.AcceptChanges();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ds.WriteXml(Server.MapPath("book.xml"));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataSource = ds;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.GridView1.DataBind();
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
相关文章推荐
- flex基础篇三 操作xml的e4x常用方式。
- TinyXml 操作XML 常用操作
- xml 常用操作
- asp.net操作xml数据常用方法小结
- node.js 操作excel 表格与XML文件常用的npm
- C# 对Xml的常用操作
- C#常用操作类库三(XML操作类)
- Flex XML/XMLList 常用操作
- IOS开发之----XML常用操作
- .NET中XML的常用操作_转摘
- java 解析/操作 xml 几种常用方式 xml的增加/删除/修改
- XML常用操作
- Javascript里使用Dom操作Xml笔记之常用函数[转]
- [winform]操作文件与xml常用方法
- XML一些常用的简单操作
- xml操作类,封装了常用的对XML文件的操作功能....
- XML的一些常用操作
- C# 对Xml的常用操作
- XML 常用操作
- C#常用操作类库三(XML操作类)