/*本地xml 转化为stream读取*/ string path=HttpContext.Current.Server.MapPath(@".\AdminConfig.xml"); Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); XmlTextReader reader = new XmlTextReader(stream); XmlDocument xd = new XmlDocument(); xd.Load(reader); /*URL格式XML,转化为stream读取*/ string url = SPContext.Current.Site.Url + @"/gasScripts/AdminConfig.xml"; HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); Stream stream = myHttpWebResponse.GetResponseStream(); XmlTextReader reader = new XmlTextReader(stream); XmlDocument xd = new XmlDocument(); xd.Load(reader); /*URL格式XML,直接读取URL*/ string url =@"http://***/gasScripts/webconfig.xml"; XmlTextReader reader = new XmlTextReader(url); XmlDocument xd = new XmlDocument(); xd.Load(reader); XmlNode node = xd.SelectSingleNode("/appSettings/add[@key='dingwen']"); Console.Write(node.Attributes["value"].Value);