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

            }
        }

  • 相关阅读:
    使用 Traefik 代理 UDP 服务
    KubeOperator界面,集群详情中的存储,存储提供商
    centos7使用yum方式安装node_exporter
    Traefik2.3.x 使用大全(更新版)
    jumpserver堡垒机版本升级,从2.14.2升级到2.16.3
    Traefik 2.0 实现灰度发布
    matplotlib 中文问题
    数据采集实战(五) 当当网童书排名
    雅可比行列式迭代及优化(golang版)
    mysql8.x docker 远程访问配置
  • 原文地址:https://www.cnblogs.com/zhenmingliu/p/2524535.html
Copyright © 2011-2022 走看看