using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using GeneralLib;
namespace SunVoteARSPPT
{
public class SunVoteLPT
{
///
/// xml文档
///
private XmlDocument xmlDoc;
///
/// xml文档的路径
///
public string xmlDocPath = "";
///
/// xml默认语言文档。杨斌 2014-11-19
///
private XmlDocument xmlDocDef;
///
/// xml默认语言路径。杨斌 2014-11-19
///
public string xmlDocPathDef = "";
///
/// 构造函数
///
public SunVoteLPT()
{
xmlDoc = new XmlDocument();
xmlDocDef = new XmlDocument();//杨斌 2014-11-19
}
///
/// 初始化语言
///
public void LoadLanguage(string xmlDocPath)
{
xmlDoc.Load(xmlDocPath);
}
///
/// 初始化语言-默认。杨斌 2014-11-19
///
///
public void LoadLanguageDef(string xmlDocPath)
{
xmlDocDef.Load(xmlDocPath);
}
///
/// 读xml文件
///
///
///
///
/// 默认值
///
public string ReadString(string element, string attribute, string dValue)
{
//string nodePath = "//Language//" + element + "//" + attribute;
//XmlNode node = xmlDoc.SelectSingleNode(nodePath);
//if (node != null)
//{
// //杨斌 2013-09-02
// dValue = node.InnerText;
// dValue = dValue.Replace("\\r\\n", "\r\n");
// return dValue;
//}
//return dValue;
try
{
string nodePath = "//Language//" + element + "//" + attribute;
//杨斌 2014-11-19
XmlNode node = null;
try
{
node = xmlDoc.SelectSingleNode(nodePath);
}
catch (Exception ex)
{
SystemLog.WriterLog(ex, false);
}
if (node == null)//没有则从默认语言加载。杨斌 2014-11-19
{
if (attribute == "lblGroupName")
attribute = attribute;
try
{
node = xmlDocDef.SelectSingleNode(nodePath);
}
catch { }
}
if (node != null)
{
//杨斌 2013-09-02
dValue = node.InnerText;
dValue = dValue.Replace("\\r\\n", "\r\n");
}
}
catch { }
return dValue;
}
}
}