Results 1 to 2 of 2
  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012

    Did I actually retrieve the xml file?

    I am trying to read open (WinhttpReq) an xml file and save it to a directory in the root of c:\. The code is pretty straight forward but I think the code is either stepping through the code too quickly or the website is taking longer to honor the request

    Dim WinHttpReq
    Set WinHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
    Dim sTemp

    ' Use the URL of the text file you wish to retrieve:
    WinHttpReq.Open "GET", "http://api.theweatherchannel.com/data/trupoint_cc/02472?doctype=xml&units=s&apikey=_MyKey_&country=US&locale=en_US", False

    If (WinHttpReq.Status = 200) Then
    sTemp = WinHttpReq.ResponseText
    ' Replace any carriage returns and linefeeds with spaces
    sTemp = Replace(sTemp, vbCr, " ")
    sTemp = Replace(sTemp, vbLf, " ")

    WebText = sTemp
    ' msgbox(webtext)

    'Create the 'weather' file
    Set objFile = objFSO.OpenTextFile("C:\myWeather.txt", 8, True)
    objFile.WriteLine sTemp
    Set objFile = Noth

    ' Failed -- return empty string
    WebText = ""
    End If

    When I run the code it does not return an error but the file does not appear in the folder.

    Is there something that I'm missing that I should be adding to allow for the host to respond and send the file. Should I put up a prompt that would expose (or post) the xml file into a dialogue box to verify the code has actually read or parsed the file?

  2. #2
    Addicted Member
    Join Date
    Jul 2009

    Re: Did I actually retrieve the xml file?

    After the Send, put:
    Wscript.echo WinHttpReq.status & " " & WinHttpReq.statusText
    to see if the Get is returning an error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width