none
how to get wather data from openweathermap RRS feed

  • Question

  • hi guys, i need get wather information from www.openweathermap.org

    i found this class in google but it's not work idk why

    Imports System.Xml
    Imports System.Net
    
    Public Class Weather_API
        Private lpCity As String
        Sub New(ByVal City As String)
            lpCity = City
        End Sub
        Public Function Get_Weather() As String
            Dim x As New XmlDocument
            Dim i As New WebClient
            x.LoadXml(i.DownloadString("http://api.openweathermap.org/data/2.5/forecast/daily?q=" & lpCity & "&mode=xml&units=metric"))
            Dim City As String = ""
            Dim Country As String = ""
            Dim lastupdate As String = ""
            Dim temp As String
            Dim humidity As String
            Dim clouds As String
            Dim windspeed As String
            For Each xn As XmlNode In x.GetElementsByTagName("name")
                City = xn.InnerText
            Next
            For Each xn As XmlNode In x.GetElementsByTagName("country")
                Country = xn.InnerText
            Next
            For Each xn As XmlNode In x.GetElementsByTagName("lastupdate")
                lastupdate = xn.InnerText
            Next
            temp = x.GetElementsByTagName("temperature")(0).Attributes(0).InnerText
            humidity = x.GetElementsByTagName("humidity")(0).Attributes(0).InnerText & "%"
            clouds = x.GetElementsByTagName("clouds")(0).Attributes(0).InnerText
            windspeed = x.GetElementsByTagName("windSpeed")(0).Attributes(0).InnerText & "MPS" & " / " & x.GetElementsByTagName("windSpeed")(0).Attributes(1).InnerText
            Dim Full As String = "Country : " & Country & " " & City & " - L.Update : " & lastupdate & " - Humidity : " & humidity & " Temperature : " & temp & " °C -" & " Clouds: " & clouds & " - WindSpeed : " & windspeed
            Return Full
        End Function
    
    End Class

    call:

     Dim WA As New Weather_API("Syria,Aleppo")
            TextBox1.Text = WA.Get_Weather

    please help me

    Tuesday, September 12, 2017 8:11 AM

All replies