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");

            }
        }

  • 相关阅读:
    DHCP DHCPv6
    DHCPv6协议
    IPv6邻居发现协议
    CentOS下禁止防火墙
    centOS下更新yum源
    centOS下yum报错
    Flink+Kafka整合的实例
    Flink基本概念
    Ubuntu16.04下配置ssh免密登录
    Zookeeper+Kafka的单节点配置
  • 原文地址:https://www.cnblogs.com/zhenmingliu/p/2524535.html
Copyright © 2011-2022 走看看