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

            }
        }

  • 相关阅读:
    Json介绍与Ajax技术
    Java学习笔记(二一)——Java 泛型
    谏牲口TT十思疏
    Java学习笔记(二十)——Java 散列表_算法内容
    Java学习笔记(十九)——Java 日志记录 AND log4j
    读书笔记(三)——《山楂树之恋》敢爱吗?
    Java学习笔记(十八)——Java DTO
    Java学习笔记(十七)——java序列化
    Java学习笔记(十六)——Java RMI
    Java学习笔记(十五)——javadoc学习笔记和可能的注意细节
  • 原文地址:https://www.cnblogs.com/zhenmingliu/p/2524535.html
Copyright © 2020-2023  润新知