ASP GetXML

Function GetXml(Xml_Url)
GetXml_Temp =""
Dim objXml
'On Error Resume Next
Set objXml = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXml.SetTimeOuts 10000, 10000, 30000, 30000

objXml.Open "GET",Xml_Url,False
objXml.Send()
If (objXml.ReadyState = 4) And (objXml.Status = 200) Then
 On Error Resume Next
   GetXml_Temp = bytes2BSTR(objXml.ResponseBody)
   If Err.Number <> 0 Then
  Err.Clear
  GetXml_Temp = BytesToBstr(objXml.ResponseBody,"windows-1252")
 End If
  
Else
   GetXml_Temp =""
End If
Set objXml = Nothing
GetXml = GetXml_Temp
If Err Then Err.Clear
End Function

Function bytes2BSTR(vIn)
Dim strreturn,i,thischarcode,nextcharcode
strReturn = ""
For i = 1 To LenB(vIn)
   ThisCharCode = AscB(MidB(vIn,i,1))
   IF ThisCharCode < &H80 THEN
    strReturn = strReturn & Chr(ThisCharCode)
   Else
    NextCharCode = AscB(MidB(vIn,i+1,1))
    strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
    i = i + 1
   End If
Next
bytes2BSTR = strReturn
End Function

Function BytesToBstr(body, Cset) ' add by woods on 2012-8-1
    Dim objstream
    Set objstream = Server.CreateObject("adodb.stream")
    objstream.Type = 1
    objstream.Mode = 3
    objstream.Open
    objstream.Write body
    objstream.Position = 0
    objstream.Type = 2
    objstream.Charset = Cset
    BytesToBstr = objstream.ReadText
    objstream.Close
    Set objstream = Nothing
End Function

posted on 2012-11-19 14:06  canny_strive  阅读(147)  评论(0编辑  收藏  举报

导航