XML文件简单操作
2008-08-19 14:57
471 查看
1读取XML文件
using System.Xml;
public static string GetAppSetting(string appSettingName)
{
XmlDocument _settings = new XmlDocument();
string FileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\我的应用程序.exe.config";
StreamReader _sr = new StreamReader(FileName);
_settings.Load(_sr);
_sr.Close();
foreach (XmlNode node in _settings["configuration"]["appSettings"])
{
if (string.Compare(appSettingName, node.Attributes["key"].Value) == 0)
{
return node.Attributes["value"].Value;
}
}
return "";
}
using System.Xml;
public static string GetAppSetting(string appSettingName)
{
XmlDocument _settings = new XmlDocument();
string FileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\我的应用程序.exe.config";
StreamReader _sr = new StreamReader(FileName);
_settings.Load(_sr);
_sr.Close();
foreach (XmlNode node in _settings["configuration"]["appSettings"])
{
if (string.Compare(appSettingName, node.Attributes["key"].Value) == 0)
{
return node.Attributes["value"].Value;
}
}
return "";
}
相关文章推荐
- 简单使用dom4j对xml文件进行输出操作(如何使用dom4j对xml文件进行输出)
- XML--- 简单的DOM解析XML文件,并实现增,删,查,改的操作
- Java采用DOM操作XML文件简单介绍
- unity3d 简单的xml文件读写操作
- 简单的操作xml ,用于在winform中配置文件.
- 简单的VC 操作XML 文件的的方法
- 简单的VC 操作XML 文件的的方法
- 简单的XML文件操作
- 简单的VC 操作XML 文件的的方法
- linq to xml 简单的增、删、改、查、保存xml文件操作
- 简单的VC 操作XML 文件的的方法
- 简单的XML文件操作(xml文件生成,节点追加、遍历、修改、删除)
- linq to xml 简单的增、删、改、查、保存xml文件操作
- 简单的VC 操作XML 文件的的方法
- 简单的VC 操作XML 文件的的方法
- C#操作xml配置文件最简单方法
- 发布一个简单实用的xml文件操作帮助类
- 简单的XML操作:XML文件创建
- 简单的VC 操作XML 文件的的方法
- XML文件简单操作