XML删除按钮,修改并保存按钮 和 添加按钮。完成这些按钮所对应的功能(XmlDocument)。

 

  protected void Button3_Click(object sender, EventArgs e)
        {
            XmlElement bo = xdoc.CreateElement("book");
            XmlElement au = xdoc.CreateElement("author");
            XmlElement pu = xdoc.CreateElement("publisher");
            XmlElement na = xdoc.CreateElement("name");
            XmlElement pr = xdoc.CreateElement("price");
            XmlElement isb = xdoc.CreateElement("isbn");
            XmlElement da = xdoc.CreateElement("date");
            xdoc.AppendChild(au);
            xdoc.AppendChild(bo);
            xdoc.AppendChild(pu);
            xdoc.AppendChild(na);
            xdoc.AppendChild(pr);
            xdoc.AppendChild(isb);
            xdoc.AppendChild(da);
            xdoc.Save(Server.MapPath("newbook2.xml"));
            this.ClientScript.RegisterClientScriptBlock(this.GetType(),"kk","<script type='text/javascript'>alter</script>");
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            XmlNode node = xdoc.DocumentElement.SelectSingleNode("book[name='" + this.DropDownList1.Text + "']");
            node.SelectSingleNode("author").InnerText = this.TextBox1.Text;
            node.SelectSingleNode("publisher").InnerText = this.TextBox2.Text;
            node.SelectSingleNode("date").InnerText = this.TextBox3.Text;
            node.SelectSingleNode("isbn").InnerText = this.TextBox4.Text;
            node.SelectSingleNode("price").InnerText = this.TextBox5.Text;
            xdoc.Save(Server.MapPath("books.xml"));

           // Page.RegisterClientScriptBlock("key1","<script type='text/javascript'>alter</script >");
            this.ClientScript.RegisterClientScriptBlock(this.GetType(),"key2","<script type='text/javascript'>alter</script >");
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            XmlNode node = xdoc.DocumentElement.SelectSingleNode("book[name='"+this.DropDownList1.Text+"']");
            xdoc.DocumentElement.RemoveChild(node);
            this.DropDownList1.Items.RemoveAt(this.DropDownList1.SelectedIndex);
            xdoc.Save(Server.MapPath("newbook.xml"));
        }
 
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值