• XML操作集合


     protected override void OnLoad(EventArgs e)
            {
                DataSet dsXML = new DataSet();

                dsXML.ReadXml(Server.MapPath(@"count.xml"));
                int count=0;

                foreach (DataRow dsRow in dsXML.Tables[0].Rows)
                {
                    if (dsRow["Number"].ToString() == "1")
                    {
                        count = Convert.ToInt32(dsRow["usercount"]);
                    }
                }

                count = count + 3;
                Label1.Text = count.ToString();
                //string fileName = "count.xml";
                //dsXML.ReadXml(Server.MapPath(@"count.xml"));
                try
                {
                    //XmlDocument doc = new XmlDocument();
                    //doc.Load(Server.MapPath(fileName));
                    //XmlElement newUser = doc.CreateElement("user");
                    //XmlAttribute newID = doc.CreateAttribute("id");
                    //newID.InnerText = "3";
                    //newUser.SetAttributeNode(newID);
                    //XmlElement newUserName = doc.CreateElement("usercount");
                    //newUserName.InnerText = count.ToString();
                    //newUser.AppendChild(newUserName);
                    //doc.DocumentElement.AppendChild(newUser);
                    //doc.Save(Server.MapPath(fileName)); 
                    foreach (DataRow dsRow in dsXML.Tables[0].Rows)
                    {
                        if (dsRow["Number"].ToString() == "1")
                        {
                            dsRow["Number"] = "1";
                            dsRow["usercount"] = count;
                            dsXML.WriteXml(Server.MapPath(@"count.xml"));
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {

                }
                finally
                { }

     

     

            }

  • 相关阅读:
    Swift_Set详解
    Swift_数组详解
    Swift_字符串详解(String)
    选择排序_C语言_数组
    插入排序_C语言_数组
    快速排序_C语言_数组
    冒泡排序_C语言_数组
    七牛直播收获分享
    iOS 实用博客整理(连载版)
    iOS Swift-元组tuples(The Swift Programming Language)
  • 原文地址:https://www.cnblogs.com/duwamish/p/1338400.html
Copyright © 2020-2023  润新知