xml文件

<?xml version="1.0" encoding="utf-8" ?>
<Config>
<dbtype>SQL Server</dbtype>
<connstr>server=.;uid=sa;pwd=123456;database=niunantest;</connstr>
<genway>0</genway>
<namespace>Niunan.Test</namespace>
<front>test_</front>
<output>d:\niunancode\</output>
</Config>

读取

       XDocument xdoc = XDocument.Load(System.Environment.CurrentDirectory + "\\appconfig.xml");

            var ad = from a in xdoc.Descendants("Config")
select new
{
dbtype = a.Element("dbtype").Value,
connstr = a.Element("connstr").Value,
genway = a.Element("genway").Value,
ns = a.Element("namespace").Value,
front = a.Element("front").Value,
output = a.Element("output").Value
};

写入

              XElement ownwe = new XElement("Config", new XElement[]{
new XElement("dbtype",dbtype),
new XElement("connstr",connstr),
new XElement("genway",genway),
new XElement("namespace",ns),
new XElement("front",front),
new XElement("output",output),
});
ownwe.Save(System.Environment.CurrentDirectory + "\\appconfig.xml");

xml文件配置新增与读取的更多相关文章

  1. web.xml 文件配置01

    web.xml 文件配置01   前言:一般的web工程中都会用到web.xml,方便开发web工程.web.xml主要用来配置Filter.Listener.Servlet等.但是要说明的是web. ...

  2. springmvc 项目完整示例07 设置配置整合springmvc springmvc所需jar包springmvc web.xml文件配置

    前面主要是后台代码,spring以及mybatis的整合 下面主要是springmvc用来处理请求转发,展现层的处理 之前所有做到的,完成了后台,业务层和持久层的开发完成了 接下来就是展现层了 有很多 ...

  3. SpringIOC注入模块中xml文件导入其他xml文件配置

    如果我们在spring框架中配置了多个xml文件,我们可以在读取配置文件的时候把这些xml文件一下全都读取 也可以只读一个总的xml文件,在这个总的xml文件中把其他的xml全都都导入进来. 例如: ...

  4. 在MFC程序中使用XML文件配置工具栏

    现在我发现使用Visual Studio的资源编辑器进行编辑资源有着诸多的不便:首先是任何资源的变动一般变动代码,不利于系统维护,其次Visual Studio的资源编辑器的本身的功能有限,也不利于界 ...

  5. Spring框架入门之基于xml文件配置bean详解

    关于Spring中基于xml文件配置bean的详细总结(spring 4.1.0) 一.Spring中的依赖注入方式介绍 依赖注入有三种方式 属性注入 构造方法注入 工厂方法注入(很少使用,不推荐,本 ...

  6. Spring整合Hibernate的XML文件配置,以及web.xml文件配置

    利用Spring整合Hibernate时的XML文件配置 applicationContext.xml <?xml version="1.0" encoding=" ...

  7. mybatis mapper xml文件配置resultmap时,id行和result行有什么区别?

    mybatis mapper xml文件配置resultmap时,id行和result行有什么区别? <resultMap id = "CashInvoiceMap" typ ...

  8. idea的spring整合基于xml文件配置的mybatis报Invalid bound statement (not found): com.music.dao.MusicDao.findAll的问题

    一. 题主当时就是自己尝试整合spring和mybatis的时候遇到了这个问题,当时题主只看到了用注解的方式配置的dao层,题主用的是xml文件配置的形式, 而且坑爹的是题主的两个文件的路径写的也不一 ...

  9. maven spark Scala idea搭建maven项目的 pom.xml文件配置

    1.pom.xml文件配置,直接上代码. <?xml version="1.0" encoding="UTF-8"?> <project xm ...

随机推荐

  1. 第三次scrum作业

    一.第三次冲刺任务 ! 在已有的基础上实现图书馆管理员对图书信息的查询以及对图书借阅情况的查询. 二.用户故事 本次的用户是图书馆的管理员 用户输入对应的管理员的账号和密码 用户选择图书查询,进入图书 ...

  2. C++题解:Matrix Power Series ——矩阵套矩阵的矩阵加速

    Matrix Power Series r时间限制: 1 Sec 内存限制: 512 MB 题目描述 给定矩阵A,求矩阵S=A^1+A^2+--+A^k,输出矩阵,S矩阵中每个元都要模m. 数据范围: ...

  3. 2019.03.28 bzoj3594: [Scoi2014]方伯伯的玉米田(二维bit优化dp)

    传送门 题意咕咕咕 思路:直接上二维bitbitbit优化dpdpdp即可. 代码: #include<bits/stdc++.h> #define N 10005 #define K 5 ...

  4. Day12 (黑客成长日记) 函数

    一.递归函数: 在函数内部,可以调用其他函数.如果一个函数在内部调用自身本身,这个函数就是递归函数. #计算阶乘: def fact(n): if n == 1: return 1 return n ...

  5. Java时间日期格式转换 转自:http://www.cnblogs.com/edwardlauxh/archive/2010/03/21/1918615.html

    Java时间格式转换大全 import java.text.*; import java.util.Calendar; public class VeDate { /** * 获取现在时间 * * @ ...

  6. webstorm验证码

    2017-2-16 亲测可用 http://idea.imsxm.com/ webstorm10 注册码 User or company Name: EMBRACE ===== LICENSE KEY ...

  7. 《python语言程序设计》_第二章编程题

    2.1 程序: Celsius=eval(input("Enter a degree in Celsius:"))#输入摄氏度的值Celsiusfahrenheit =(9/5)* ...

  8. [转] Java 的泛型擦除和运行时泛型信息获取

    原文链接 https://my.oschina.net/lifany/blog/875769 前言 现在很多程序员都会在简历中写上精通 Java.但究竟怎样才算是精通 Java 呢?我觉得不仅要熟练掌 ...

  9. 1.1.5 PROB Friday the Thirteenth

    Friday the Thirteenth Is Friday the 13th really an unusual event? That is, does the 13th of the mont ...

  10. 吴恩达机器学习笔记14-逻辑回归(Logistic Regression)

    在分类问题中,你要预测的变量