我正在使用 httpwebrequest 从网站获取响应。在这个响应中,我应该看到一个 xml。但在我的回应中,它只是让我觉得很乱。我用提琴手看看我得到了什么。我得到一个编码响应,我需要手动对其进行解码以查看内容(这是在提琴手中)。
我怎样才能在 vb.net 中做同样的事情?
编辑响应返回为https。
我试过了:
HttpUtility.HtmlDecode(myResult,myStreamwriter)
Dim request As HttpWebRequest = DirectCast(WebRequest.Create("www.url.com/$filetype=xml"), HttpWebRequest)
request.KeepAlive = True
request.UserAgent = "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11"
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
request.ContentType = "text/xml, charset=utf-8"
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip,deflate,sdch")
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4")
request.Headers.Set(HttpRequestHeader.AcceptCharset, "ISO-8859-1,utf-8;q=0.7,*;q=0.3")
Using getResponse = request.GetResponse
Dim webServiceResponse = getResponse.GetResponseStream()
Dim xmlreader As New IO.StreamReader(webServiceResponse)
'here is where it shows a really gibberish output
Dim myResult As String = xmlreader.ReadToEnd()