zoukankan      html  css  js  c++  java
  • c# 读改xml

    class ServerUtils
        {
             private static ServerUtils _instance = new ServerUtils();
            public static ServerUtils getInstance()
            {
                return _instance;
            }
            XmlDocument doc = new XmlDocument();
           
            private string serverIp;
            private string typecode;
            public string getServerIp()
            {
                doc.Load("XMLFile1.xml");
                XmlNode node = doc.SelectSingleNode("tongbu/server_ip");
                serverIp = node.FirstChild.Value;
                return serverIp;
            }
            public string gettypecheck()
            {
                XmlDocument doc = new XmlDocument();
                doc.Load("XMLFile1.xml");
                XmlNode node = doc.SelectSingleNode("tongbu/type");
                typecode = node.FirstChild.Value;
                return typecode;
            }
            public void ModifServerIP(string str)
            {
                XmlDocument doc = new XmlDocument();
                doc.Load("XMLFile1.xml");
                XmlNode node = doc.SelectSingleNode("tongbu/server_ip");
                XmlElement xe = (XmlElement)node;
                xe.InnerText = str;
                doc.Save("XMLFile1.xml");
              
            }
            public void Modiftypecode(string str)
            {
                XmlDocument doc = new XmlDocument();
                doc.Load("XMLFile1.xml");
                XmlNode node = doc.SelectSingleNode("tongbu/type");
                XmlElement xe = (XmlElement)node;
                xe.InnerText = str;
                doc.Save("XMLFile1.xml");

            }
        }

  • 相关阅读:
    innerHTML和outerHTML的区别
    递归,汉诺塔
    js 中的 Math.ceil() Math.floor Math.round()
    JS中的异常exception
    CSS样式中visited,hover,active , focus这四个分别表示什么意思?
    用户在设置密码时,提醒请输入半角字符(vue+element+valid)
    设置用户密码时,将全角转换为半角
    后台返回对象数组,对象属性相同时,只取一个对象
    远程链接mongoDB robomongo
    mongodb 入坑
  • 原文地址:https://www.cnblogs.com/zhenmingliu/p/2524535.html
Copyright © 2011-2022 走看看