Xml读取
var server = 4; try { XmlDocument xmlDoc = new XmlDocument(); string xmlPath = AppDomain.CurrentDomain.BaseDirectory + "XML/ChannelConfig.xml"; //获取xml文件路径 xmlDoc.Load(xmlPath); var Key = ; string strNodePath = string.Format("/root/Channel[@Key="{0}"]", Key); XmlNode xn = xmlDoc.SelectSingleNode(strNodePath); if (xn != null) { server = Convert.ToInt32(xn.Attributes["server"].Value); } } catch (Exception ex) { }