我尝试使用以下代码从URL获取XML数据:
WebRequest webRequest = WebRequest.Create(Url);
using (WebResponse webResponse = await webRequest.GetResponseAsync())
{
using (Stream responseStream = webResponse.GetResponseStream())
{
XmlDocument XmlDoc = new XmlDocument();
XmlDoc.Load(webResponse); ////error
}
}
Visual Studio既不接受"XMLDoc.Load()“,也不接受"XMLDoc.LoadXml()”--那么,我如何从webrequest中获取xmldoc呢?谢谢
发布于 2012-12-02 22:43:02
这应该是可行的:
string url = @"http://ws.audioscrobbler.com/2.0/?method=geo.getevents&location=" + ub.Ciudad + "&page=1&api_key=" + LAST_API_KEY; //for example
XmlDocument xDoc = await XmlDocument.LoadFromUriAsync(new Uri(url)); //this does the web request
https://stackoverflow.com/questions/13673124
复制