WinHttp.WinHttpRequest如何处理XML文档
本帖最后由 muyiqinghan 于 2010-12-28 18:04:57 编辑 WinHttp.WinHttpRequest.5.1 组件有没有处理返回XML文档的方法
ResponseXML报错,用ResponseText返回了字符串型,但显示不了!
代码:
URL = "http://127.0.0.1/Test/Test.xml"
Data = "None"'"type=ip&q=123.233.157.9"
Cookie = "None"
Set WinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
WinHttp.Option(4) = 13056
WinHttp.Option(6) = 0 '不抓取跳转页面的信息
WinHttp.SetTimeouts 10000, 10000, 10000, 60000
WinHttp.Open "GET", URL + "?" + Data, False '以同步模式打开URL
WinHttp.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
WinHttp.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"
WinHttp.SetRequestHeader "Accept-Language", "zh-cn"
'WinHttp.SetRequestHeader "Host","www.baidu.com" '不能加此HTTP头信息WinHttp.SetRequestHeader "Cookie", Cookie
WinHttp.SetRequestHeader "Connection", "Keep-Alive"
WinHttp.Send Null 'Parm
If WinHttp.Status = 200 Then
Response_Head = WinHttp.GetAllResponseHeaders
Response.Write(Response_Head)
'Response_Type = WinHttp.GetResponseHeader("Content-Type")
'Response_Cookie = WinHttp.GetResponseHeader("Set-Cookie")
Response_Xml_Temp = WinHttp.ResponseText
Response.Write(TypeName(Response_Xml_Temp))
Response.Write(Response_Xml_Temp)
'Response_Xml = Response_Xml_Temp
'Response.Write(Response_Xml_Temp)
ConnectXml = True
End If
If Err.Number <> 0 Then
ConnectXml = "Get: An error occurred while operating procedures"
End If
Set WinHttp = Nothing
而XMLHTTP和ServerXMLHTTP都可以得到XML文档
[解决办法]
XMLDocument对象LoadXML
[解决办法]
ResponseXML就是一个XML DOMDocument对象。