Tag Archives: VisualBasic

Through VB: Get Weather Information Using Web Service

21 Feb

Dim Req As New XMLHTTP
Dim Resp As New DOMDocument
Dim Weather As IXMLDOMNode
Dim CurrentWeather As IXMLDOMNode

Req.Open “GET”, “http://api.worldweatheronline.com/free/v1/weather.ashx?q=Karachi&format=xml&num_of_days=1&key=enter_you_own_key_by-registering”, False
Req.Send
Resp.loadXML (Req.responseText)

For Each CurrentWeather In Resp.getElementsByTagName(“current_condition”)
Me.LabelTemp.Caption = ” ” & CurrentWeather.SelectNodes(“temp_C”)(0).Text
Me.LabelTemp1.Caption = ” ” & CurrentWeather.SelectNodes(“humidity”)(0).Text
Me.LabelTemp2.Caption = ” ” & CurrentWeather.SelectNodes(“windspeedKmph”)(0).Text
Me.LabelTemp4.Caption = ” ” & CurrentWeather.SelectNodes(“winddir16Point”)(0).Text
Me.LabelTemp3.Caption = ” ” & CurrentWeather.SelectNodes(“pressure”)(0).Text

Next