读xml,
public static string ReadXMLConfig(string strFileName, string sKey)
{
// string strFileName = "Brand.exe.config";
XmlDocument oXmlDocument = new XmlDocument();
string strReturn="";
try
{
oXmlDocument.Load(Application.StartupPath+"\\"+strFileName);
XmlNodeList oXmlNodeList = oXmlDocument.DocumentElement.ChildNodes;
foreach (XmlElement oXmlElement in oXmlNodeList)
{
if (oXmlElement.Name.ToLower() == "appsettings")
{
XmlNodeList _node = oXmlElement.ChildNodes;
if (_node.Count > 0)
{
foreach (XmlElement _el in _node)
{
if (_el.Attributes["key"].InnerXml.ToLower() == sKey.ToLower())
{
strReturn = _el.Attributes["value"].Value;
break;
}
}
}
}
}
}
catch (Exception exp)
{
if (sKey.ToLower() == "dsn")
{
&nbs