C# 读取配置文件方法
如 xml中写:
<?xml version="1.0" encoding="utf-8" ?>
<config>
<serv_ip>192.168.0.105</serv_ip>
<database>test</database>
<userid>sa</userid>
<password>123456</password>
</config>
那么代码:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("config.xml");
XmlNode root = xmlDoc.SelectSingleNode("config");//指向根节点
XmlNode xn = root.SelectSingleNode("serv_ip");//指向根节点下的serv_ip节点
string ip = xn.InnerText;//读出里面的值 注意读取的是string 需要类型转换的话自己做
XmlNode database = root.SelectSingleNode("database");
string data = database.InnerText;
XmlNode userid = root.SelectSingleNode("userid");
string user = userid.InnerText;
XmlNode password = root.SelectSingleNode("password");
string pwd = password.InnerText;
C# 读取配置文件方法的更多相关文章
- asp.net 读取配置文件方法
方法1: System.Collections.Specialized.NameValueCollection nvc = (System.Collections.Specialized.NameVa ...
- java读取配置文件方法以及工具类
第一种方式 : java工具类读取配置文件工具类 只是案例代码 抓取异常以后的代码自己处理 import java.io.FileNotFoundException; import java.io. ...
- python 读取配置文件方法
#coding=utf8 import ConfigParser config = ConfigParser.ConfigParser() config.readfp(open(raw_input(& ...
- PHP读取配置文件连接MySQL数据库
读取配置文件方法parse_ini_file($filepath [,$section]) 代码: conn.php <?php //连接数据库 //$conn =new mysqli('loc ...
- java读取配置文件的几种方法
java读取配置文件的几种方法 原文地址:http://hbcui1984.iteye.com/blog/56496 在现实工作中,我们常常需要保存一些系统配置信息,大家一般都会选择配 ...
- Shell读取配置文件的方法
参考:http://www.cnblogs.com/binbinjx/p/5680214.html 做批量软件安装自动化时,都喜欢用配置文件的方式改变参数,那怎么通过shell读取配置文件的配置呢?参 ...
- java web 读取配置文件两种方法
package com.tsinghua.getDataBaseConn; import java.io.IOException;import java.io.InputStream;import j ...
- Log4j 2.0读取配置文件的方法
log4j中配置日志文件存放的位置不一定在src下面,即根目录下.这个时候我们需要解决如何加载配置文件的问题.在log4j1.x中解决的方法就比较多了.如:PropertyConfigurator.c ...
- Springboot读取配置文件的两种方法
第一种: application.yml配置中的参数: zip: Hello Springboot 方法读取: @RestController public class ControllerTest ...
随机推荐
- win7安装mysql-8.0.13-winx64
这里展示一下,由于需要安装一个版本测试一下数据,其实就是超简单的啦. 下包 注:https://dev.mysql.com/downloads/mysql/ 解压与配置 [mysqld] basedi ...
- nmap扫描内网存活机器脚本
nmap扫描内网存活机器并保存在指定文件中. host.sh #/usr/bin/bash read -p "Please input scan host or network:" ...
- python&django 常见问题及解决方法
0.python-dev安装(ubuntu) apt-get install python-dev 1.Open(filename,mode) 报错实例: f = open('d:\Users\16 ...
- Bootstrap3基础 navbar 导航条 简单示例
内容 参数 OS Windows 10 x64 browser Firefox 65.0.2 framework Bootstrap 3.3.7 editor ...
- Python3基础 dict in/not in 查询一个字符是否指定字典的键或者值
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- upc组队赛1 不存在的泳池【GCD】
不存在的泳池 题目描述 小w是云南中医学院的同学,有一天他看到了学校的百度百科介绍: 截止到2014年5月,云南中医学院图书馆纸本藏书74.8457万册,纸质期刊388种,馆藏线装古籍图书1.8万册, ...
- Depth-first search and Breadth-first search 深度优先搜索和广度优先搜索
Depth-first search Depth-first search (DFS) is an algorithm for traversing or searching tree or grap ...
- Eclipse 创建maven项目 报错 one or more constraints have not been satisfied
首先 在 pom.xml > plugins 中添加 <plugin> <groupId>org.apache.maven.plugins</groupId> ...
- js 二分搜索树删除子节点
删除的节点含有左子树或者右子树,用其子树来代替成为被删除节点的父节点的子树 删除左右都有孩子的节点,找到右边子树最小的节点作为父节点
- P5057 [CQOI2006]简单题(线段树)
果然简单题,5分钟紫题++ 代码 #include <cstdio> #include <algorithm> #include <cstring> using n ...