本文实例讲述了C#获取远程XML文档的方法。分享给大家供大家参考,具体如下: private XDocument GetXDocument(string url){ Uri uri = new Uri(url); System.Net.WebClient wb = new System.Net.WebClient(); wb.Proxy.Cred
本文实例讲述了C#获取远程XML文档的方法。分享给大家供大家参考,具体如下:
private XDocument GetXDocument(string url) { Uri uri = new Uri(url); System.Net.WebClient wb = new System.Net.WebClient(); wb.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials; MemoryStream ms = new MemoryStream(wb.DownloadData(uri)); System.Xml.XmlTextReader rdr = new System.Xml.XmlTextReader(ms); XDocument doc = XDocument.Load(rdr); return doc; }
希望本文所述对大家C#程序设计有所帮助。