• 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
                { }

     

     

            }

  • 相关阅读:
    恶意代码检测--已看梳理
    tips
    十大排序
    python使用记录
    Matlab用figure;subplot后合并子图
    利用python的docx模块处理word和WPS的docx格式文件
    论文笔记(FCN网络,语义分割):Fully Convolutional Networks for Semantic Segmentation
    论文笔记:SoundNet: Learning Sound Representations from Unlabeled Video
    Winner-Take-All Autoencoders ( 赢者通吃自编码器)
    机器学习优化过程中的各种梯度下降方法(SGD,AdaGrad,RMSprop,AdaDelta,Adam,Momentum,Nesterov)
  • 原文地址:https://www.cnblogs.com/duwamish/p/1338400.html
Copyright © 2020-2023  润新知