读取XML文件
来源:互联网 发布:罗马 汉 知乎 编辑:程序博客网 时间:2024/06/11 06:32
string path = System.AppDomain.CurrentDomain.BaseDirectory + "Config/Page.xml";
if (!File.Exists(path))
{
return;
}
//载入页面设置(读取XML文件)
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(path);
if (xmlDoc == null)
{
return;
}
XmlNodeList nodes = xmlDoc.SelectNodes("/PageCache/Page");
string name = string.Empty;
int time = 0;
foreach (XmlNode node in nodes)
{
name = "/" + node.Attributes["Name"].Value.ToString().TrimStart('/').ToLower(); //XML 文件节点名为Name的值,如果第一个位置没有“/”则添加,如果有,则忽略。
time = Shove._Convert.StrToInt(node.Attributes["CacheTime"].Value, 0); //取节点名为CacheTime的值
if (string.IsNullOrEmpty(name))
{
return;
}
_Settings.Add(name, time);
}
}
catch (Exception ex)
{
SitePublicFunction.RecordError(ex);
}
finally
{
xmlDoc = null;
}
if (!File.Exists(path))
{
return;
}
//载入页面设置(读取XML文件)
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(path);
if (xmlDoc == null)
{
return;
}
XmlNodeList nodes = xmlDoc.SelectNodes("/PageCache/Page");
string name = string.Empty;
int time = 0;
foreach (XmlNode node in nodes)
{
name = "/" + node.Attributes["Name"].Value.ToString().TrimStart('/').ToLower(); //XML 文件节点名为Name的值,如果第一个位置没有“/”则添加,如果有,则忽略。
time = Shove._Convert.StrToInt(node.Attributes["CacheTime"].Value, 0); //取节点名为CacheTime的值
if (string.IsNullOrEmpty(name))
{
return;
}
_Settings.Add(name, time);
}
}
catch (Exception ex)
{
SitePublicFunction.RecordError(ex);
}
finally
{
xmlDoc = null;
}
0 0
- SAX 读取xml文件
- xml文件读取
- 读取xml文件内容
- 读取xml 文件
- JAVA读取XML文件
- 读取远程xml文件
- XML文件的读取
- Xml文件的读取
- JAVA读取XML文件
- 读取XML文件
- flash读取xml文件
- C#读取XML文件
- javascript 读取XML文件
- 读取xml 文件
- XML文件的读取
- 读取XML文件
- JAVA读取XML文件
- JAVA读取XML文件
- 尝试了所有的服务器都无法成功连接服务器。。。。。
- byte order
- ios自定义相机并加水印实现流程
- 数据结构学习 串的表示和实现
- ERROR :fatal error LNK1103: debugging information corrupt; recompile module
- 读取XML文件
- c/C++内存分配
- vc2010 属性值无效 灾难性故障 解决方法
- 表单验证1
- PHP对表单提交特殊字符的过滤和处理
- 内存地址对齐
- how to write a makefile
- POJ-2524(并查集)
- WORD03,WOR07 和PPT转HTML