using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Xml;
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        XmlDocument myxmldoc1 = new XmlDocument();
        myxmldoc1.Load(Server.MapPath("XMLFile.xml"));
        string mystr1 = "<学号>" + TextBox1.Text + "</学号>";
        string mystr2 = "<姓名>" + TextBox2.Text + "</姓名>";
        string mystr3 = "<年龄>" + TextBox3.Text + "</年龄>";
        string mystr4 = "<班级>" + TextBox4.Text + "</班级>";
        string mystr5 = "<地址>" + TextBox5.Text + "</地址>";
        string mys = "<学生名单>" + "<学生>" + mystr1 + mystr2 + mystr3 + mystr4 + mystr5 + "</学生>" + "</学生名单>";
        XmlDocument myxmldoc2 = new XmlDocument();
        myxmldoc2.LoadXml(mys);
        XmlNode newnode = myxmldoc1.ImportNode(myxmldoc2.DocumentElement.LastChild, true);
        myxmldoc1.DocumentElement.AppendChild(newnode);
        myxmldoc1.Save(Server.MapPath("XMLFile.xml"));
        Response.Write("<script language=javascript>alert('成功插入XML数据节点！')</script>");
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "";
        TextBox2.Text = "";
        TextBox3.Text = "";
        TextBox4.Text = "";
        TextBox5.Text = "";
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("Showxml.aspx");
    }
}
