zoukankan      html  css  js  c++  java
  • 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
                { }

     

     

            }

  • 相关阅读:
    游千佛塔有感
    时刻坚持高标准:成大事者的十条“箴言”
    谁愿意嫁给我这样的人
    成功的秘诀之一,就是敢于提出大设想、大思考
    寒冬里的暖阳
    世界最伟大的管理原则
    把你藏在心里
    登天门有感
    办公室保持最佳状态的诀窍
    “领悟”的价值是什么?思维能力训练问答
  • 原文地址:https://www.cnblogs.com/duwamish/p/1338400.html
Copyright © 2011-2022 走看看