从xml获取价值 [英] get value from xml

查看:63
本文介绍了从xml获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<设置>
< add key ="connectionString" value ="DATABASE = casedb; SERVER = localhost;用户ID = root123;密码= 123;">



我的xml文件是这样的....在这里,我想获取"DATABASE = casedb; SERVER = localhost;用户ID = root123; password = 123;"值作为使用vb.net的Windows应用程序的连接字符串的值……请有人可以帮助我.....

<settings>
<add key="connectionString" value="DATABASE=casedb;SERVER=localhost;user id=root123;password=123;">



my xml file is like this.... In here I want to get the "DATABASE=casedb;SERVER=localhost;user id=root123;password=123;" value as connection string of my windows application using vb.net...... please can any one help me.....

推荐答案

看看负责所有这些工作的System.Configuration

您的app.config可以读取为


Have a look into System.Configuration which takes care of all this

Your app.config can read as


<configuration>
  <connectionStrings>
    <add name="SecurityConnectionString" connectionString="Data Source=YOURSERVERNAME;Initial Catalog=AspNetDb;User ID=YourUser;Password=YourPassword" providerName="System.Data.SqlClient"/>
  </connectionStrings>
</configuration>





引用System.Configuration,您可以按以下方式访问此连接字符串





Reference System.Configuration and you can access this connection string as follows

string connectionString = ConfigurationManager.ConnectionStrings["SecurityConnectionString"].ConnectionString;


这篇关于从xml获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆