public static ConfigUserInfo GetAppXmlDom(string strHostUrl) { ConfigUserInfo u = new ConfigUserInfo(); string filename = System.Windows.Forms.Application.ExecutablePath + ".config"; XmlDocument doc = new XmlDocument(); doc.Load(filename); //加载配置文件 //XmlNodeList NodeList = doc.SelectNodes("//configuration/ConfigUserInfo/users"); XmlNode node = doc.SelectSingleNode(string.Format("//configuration/ConfigUserInfo/users[@HostUrl='{0}']", strHostUrl)); if (node != null) { XmlElement childElement = (XmlElement)node; u.HostUrl = childElement.GetAttribute("HostUrl"); u.ServerName = childElement.GetAttribute("ServerName"); u.UserName = childElement.GetAttribute("UserName"); u.PassWord = childElement.GetAttribute("PassWord"); u.DataBaseName = childElement.GetAttribute("DataBaseName"); u.HostName = childElement.GetAttribute("HostName"); return u; } else { return null; } //node.SelectSingleNode("//ServerName") //XmlSerializer x = new XmlSerializer(typeof(ConfigUserInfo)); //using (StringReader sr = new StringReader(node.InnerXml)) //{ // ConfigUserInfo s = (ConfigUserInfo)x.Deserialize(sr); //} //ConfigUserInfo/users }
//得到第一个节点数据库连接信息 public static ConfigUserInfo GetAppXmlDom_Default() { ConfigUserInfo u = new ConfigUserInfo(); string filename = System.Windows.Forms.Application.ExecutablePath + ".config"; XmlDocument doc = new XmlDocument(); doc.Load(filename); //加载配置文件 XmlNode node = doc.SelectSingleNode(string.Format("//configuration/ConfigUserInfo/users")); if (node != null) { XmlElement childElement = (XmlElement)node; u.HostUrl = childElement.GetAttribute("HostUrl"); u.ServerName = childElement.GetAttribute("ServerName"); u.UserName = childElement.GetAttribute("UserName"); u.PassWord = childElement.GetAttribute("PassWord"); u.DataBaseName = childElement.GetAttribute("DataBaseName"); u.HostName = childElement.GetAttribute("HostName"); return(u); } else { return(null); } }
public static ConfigUserInfo GetAppXmlDom(string strHostUrl) { ConfigUserInfo u = new ConfigUserInfo(); string filename = System.Windows.Forms.Application.ExecutablePath + ".config"; XmlDocument doc = new XmlDocument(); doc.Load(filename); //加载配置文件 //XmlNodeList NodeList = doc.SelectNodes("//configuration/ConfigUserInfo/users"); XmlNode node = doc.SelectSingleNode(string.Format("//configuration/ConfigUserInfo/users[@HostUrl='{0}']", strHostUrl)); if (node != null) { XmlElement childElement = (XmlElement)node; u.HostUrl = childElement.GetAttribute("HostUrl"); u.ServerName = childElement.GetAttribute("ServerName"); u.UserName = childElement.GetAttribute("UserName"); u.PassWord = childElement.GetAttribute("PassWord"); u.DataBaseName = childElement.GetAttribute("DataBaseName"); u.HostName = childElement.GetAttribute("HostName"); return(u); } else { return(null); } //node.SelectSingleNode("//ServerName") //XmlSerializer x = new XmlSerializer(typeof(ConfigUserInfo)); //using (StringReader sr = new StringReader(node.InnerXml)) //{ // ConfigUserInfo s = (ConfigUserInfo)x.Deserialize(sr); //} //ConfigUserInfo/users }
//得到第一个节点数据库连接信息 public static ConfigUserInfo GetAppXmlDom_Default() { ConfigUserInfo u = new ConfigUserInfo(); string filename = System.Windows.Forms.Application.ExecutablePath + ".config"; XmlDocument doc = new XmlDocument(); doc.Load(filename); //加载配置文件 XmlNode node = doc.SelectSingleNode(string.Format("//configuration/ConfigUserInfo/users")); if (node != null) { XmlElement childElement = (XmlElement)node; u.HostUrl = childElement.GetAttribute("HostUrl"); u.ServerName = childElement.GetAttribute("ServerName"); u.UserName = childElement.GetAttribute("UserName"); u.PassWord = childElement.GetAttribute("PassWord"); u.DataBaseName = childElement.GetAttribute("DataBaseName"); u.HostName = childElement.GetAttribute("HostName"); return u; } else { return null; } }