• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

msxml caching information?

I am new to msxml and need some clarification on some things.  I want msxml to get some xml files off a couple of servers. The servers update the xml file every 15 mins or so in order to keep everything current. However my machine will only get the information once and return the same information every time after that. To get new information I have to exit the application and reopen it.  Im thinking that there is an easy fix but have no clue what it could be.
0
Brattlof54
Asked:
Brattlof54
  • 5
  • 3
1 Solution
 
Brattlof54Author Commented:
Here is the code im trying to use.
Private xmldoc As DOMDocument
Private http As XMLHTTP
 
Set http = New XMLHTTP
http.Open "POST", "http://www.website.com", True
http.setRequestHeader "Content-type", "Text/xml"
http.send
Set xmldoc = http.responseXML

Open in new window

0
 
abelCommented:
The pages are indeed cached, also if you use XMLHTTP. If you don't want that, set No-Cache headers on the server, if you can access that code.

if you cannot, an easy method to request a new copy of a page is to add something to the querystring that is different every time:

Private xmldoc As DOMDocument
Private http As XMLHTTP
Private someRandomString As String = Rnd(Timer())
 
Set http = New XMLHTTP
http.Open "POST", "http://www.website.com/?random=" & someRandomString, True
http.setRequestHeader "Content-type", "Text/xml"
http.send
Set xmldoc = http.responseXML

Open in new window

0
 
Brattlof54Author Commented:
I tried that and for some reason the server wont return anything at all.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
abelCommented:
> I tried that and for some reason the server wont return anything at all.
can you show me how you tried it? There's usually a page involved, like index.html or something, include that to make sure your server understands the request, like this:

http.Open "POST", "http://www.website.com/index.html?random=" & someRandomString, True
If that doesn't work, please show the code you have so far.

-- Abel --
0
 
Brattlof54Author Commented:

Private xmldoc As DOMDocument
Private http As XMLHTTP
Dim RandomThing as Byte
Dim Node As IXMLDOMNode
Dim NodeList As IXMLDOMNodeList
 
Sub GetMETARs_xml()
 
RandomThing = Second(Now)
Set http = New XMLHTTP
With http
    .Open "POST", "http://weather.aero/dataserver_current/current/metars.current.xml/?Random=" & RandomNum, False
    .setRequestHeader "Content-type", "Text/xml"
    .send
End With
Set doc = url.responseXML
Set NodeList = doc.selectNodes("//METAR")
 
For Each Node In NodeList
    'parse the new information
Next
 
End Sub

Open in new window

0
 
Brattlof54Author Commented:
This is what I have so far.
0
 
abelCommented:
Showing the real code always helps, thanks. I tried the link. You should remove the slash. Apologies if my earlier post made you think it should've been different, I tried to correct that in my later post. Anyway, try this to make it work:

With http
    .Open "POST", "http://weather.aero/dataserver_current/current/metars.current.xml?Random=" & RandomNum, False
    .setRequestHeader "Content-type", "Text/xml"
    .send
End With

Open in new window

0
 
Brattlof54Author Commented:
Thank you very much. That worked out perfectly. This is what it looks like.
Private xmldoc As DOMDocument
Private http As XMLHTTP
Dim RandomThing as Byte
Dim Node As IXMLDOMNode
Dim NodeList As IXMLDOMNodeList
 
Sub GetMETARs_xml()
 
RandomThing = Second(Now)
Set http = New XMLHTTP
With http
    .Open "POST", "http://weather.aero/dataserver_current/current/metars.current.xml?Random=" & RandomThing, False
    .setRequestHeader "Content-type", "Text/xml"
    .send
End With
Set doc = http.responseXML
Set NodeList = xmldoc.selectNodes("//METAR")
 
For Each Node In NodeList
    'parse the new information
Next
 
End Sub

Open in new window

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now