(1) For example,
<html>
<head>
<title>Weather report</title>
</head>
<body bgcolor="#ccccff">
<%
Function DateTime(Epoch)
dateResult
= CDate(#12/31/1969 06:00:00PM#) ' Adjust Epoch UCT time to
Houston by subtracting 6 hours.
dateResult
= DateAdd("s", Epoch, dateResult)
DateTime =
FormatDateTime(dateResult, vbGeneralDate)
End Function
' Get weather report
from http://zowie.metnet.navy.mil/cgi-bin/oleg/get-obs
' with the Post
method with the parameter name=KHOU, etc. KHOU is the name
' of the weather
station. Other stations:
'
KHOU: Houston/Hobby
'
KEFD: Houston/Ellington
'
KSGR: Houston/Sugarland
'
KRPE: Sabine Pass
'
KRSP2: Sabine
'
KBAZ: New Braunfels
' Global constants
WEATHER_SOURCE_URL = "http://zowie.metnet.navy.mil/cgi-bin/oleg/get-obs"
DEFAULT_STATION = "KHOU"
' Get user Station
parameter.
If (Request.Form("station")
<> "") Then
strStation
= Request.Form("station")
Else If (Request.QueryString("station")
<> "") Then
strStation = Request.QueryString("station")
Else
strStation = DEFAULT_STATION
End If
End If
' Get Weather XML
file: Weather Observation Definition Format (OMF)
' Description of
OMF:
'
http://zowie.metnet.navy.mil/~spawar/JMV-TNG/XML/OMF.html
' Description of
the SYG element:
'
http://zowie.metnet.navy.mil/~spawar/JMV-TNG/XML/OMF-SYNOP.html#Elem.SYN.SYG
Set xobj = CreateObject("SOFTWING.ASPtear")
On Error Resume Next
' URL, action:1 Post, payload,
username, password
strRetval = xobj.Retrieve(WEATHER_SOURCE_URL,
1, "call_id=" & strStation & "&do-retrieve=Retrieve", "", "")
strRetval = "<?xml version=""1.0""?>"
& vbCRLF & strRetval
If Err.Number <> 0 Then
Response.write
"Sorry, the server cannot get weather information."
Response.End
End If
' Invoke XML DOM
Parser
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.async = False
objXML.validateOnParse = False
objXML.LoadXML(strRetval)
If objXML.parseError.errorCode
<> 0 Then
Response.write
"Sorry, no weather information for " & Station & "."
End If
strResult = ""
' Loop through all
SYN elements
Set objLst = objXML.getElementsByTagName("SYN")
For i = 0 to (objLst.length
- 1)
' Get
timestamp.
strTimeStamp = objLst.item(i).attributes.getNamedItem("TStamp").nodeValue
Set objSYGNode = objLst.item(i).getElementsByTagName("SYG").item(0)
strTemperature = objSYGNode.attributes.getNamedItem("T").nodeValue
strDewPoint = objSYGNode.attributes.getNamedItem("TD").nodeValue
strPressure = objSYGNode.attributes.getNamedItem("P").nodeValue
strVisibility = objSYGNode.attributes.getNamedItem("Vis").nodeValue
strWind = objSYGNode.attributes.getNamedItem("Wind").nodeValue
strResult = strResult & "<TR><TD>" & DateTime(CLng(strTimeStamp))
& "</TD><TD>" _
& strTemperature & "</TD><TD>" _
& strDewPoint & "</TD><TD>"
_
& strPressure & "</TD><TD>"
_
& strVisibility & "</TD><TD>" _
& strWind & "</TD></TR>" & LFCR
Next
If strResult = "" Then
Response.write
"Sorry, no weather information for station " & strStation
Else
Response.write
"Weather information for station " & strStation & ": <P>"
Response.write
"<TABLE BORDER=1><TR><TD BGCOLOR=#CCFFFF>Time (Houston)</TD><TD
BGCOLOR=#CCFFFF>Temperature (C)</TD><TD BGCOLOR=#CCFFFF>Dew Point
(C)</TD><TD BGCOLOR=#CCFFFF>Pressure (hPA)</TD><TD BGCOLOR=#CCFFFF>Visibility
(m)</TD><TD BGCOLOR=#CCFFFF>Wind (direction, speed in m/s)</TD></TR>"
_
& strResult _
& "</TABLE>"
End If
%>
</body>
</html>