在 vb.NET 中使用授权 HTTP 请求返回的 XML
如何在 xmltextreader 中使用阅读器返回的 XML?
' Create the web request
request = DirectCast(WebRequest.Create("https://mobilevikings.com/api/1.0/rest/mobilevikings/sim_balance.xml"), HttpWebRequest)
' Add authentication to request
request.Credentials = New NetworkCredential("username", "password")
' Get response
response = DirectCast(request.GetResponse(), HttpWebResponse)
' Get the response stream into a reader
reader = New StreamReader(response.GetResponseStream())
预先感谢,
内森。
How can I use the returned XML from the reader in a xmltextreader?
' Create the web request
request = DirectCast(WebRequest.Create("https://mobilevikings.com/api/1.0/rest/mobilevikings/sim_balance.xml"), HttpWebRequest)
' Add authentication to request
request.Credentials = New NetworkCredential("username", "password")
' Get response
response = DirectCast(request.GetResponse(), HttpWebResponse)
' Get the response stream into a reader
reader = New StreamReader(response.GetResponseStream())
Thanks in advance,
Nathan.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要创建新的 StreamReader,只需使用 GetResponseStream
You don't need to create new StreamReader, just use GetResponseStream