9 Şubat 2015 Pazartesi

Google Api OpenWeatherMap 7 Days Weather Condition Asp.net

Weather Conditıon Read From OpenWeatherMap XML.

 private void getWeather()
        {
            XmlDocument doc1 = new XmlDocument();
            doc1.Load("http://api.openweathermap.org/data/2.5/forecast/daily?q=izmir&mode=xml&units=metric&cnt=7");
            XmlElement root = doc1.DocumentElement;
            XmlNodeList timenodes = root.SelectNodes("/weatherdata");
            XmlNodeList nodes = root.SelectNodes("/weatherdata/forecast/time");


            foreach (XmlNode node in nodes)
            {
                string time = node.Attributes["day"].InnerText;
                string condition = node.SelectSingleNode("symbol").Attributes["name"].InnerText;

                string precipitation = node.SelectSingleNode("precipitation").Attributes["type"].InnerText;

                string windDeg = node.SelectSingleNode("windDirection").Attributes["deg"].InnerText;
                string windDirection = node.SelectSingleNode("windDirection").Attributes["name"].InnerText;

                string windSpeed = node.SelectSingleNode("windSpeed").Attributes["mps"].InnerText;
                string windCondition = node.SelectSingleNode("windSpeed").Attributes["name"].InnerText;

                string tempday = node.SelectSingleNode("temperature").Attributes["day"].InnerText;
                string tempmin = node.SelectSingleNode("temperature").Attributes["min"].InnerText;
                string tempmax = node.SelectSingleNode("temperature").Attributes["max"].InnerText;
                string tempnight = node.SelectSingleNode("temperature").Attributes["night"].InnerText;
                string tempeve = node.SelectSingleNode("temperature").Attributes["eve"].InnerText;
                string tempmorn = node.SelectSingleNode("temperature").Attributes["morn"].InnerText;

                string humidityVal = node.SelectSingleNode("humidity").Attributes["value"].InnerText + node.SelectSingleNode("humidity").Attributes["unit"].InnerText;

                string cloudval = node.SelectSingleNode("clouds").Attributes["value"].InnerText;
                string cloudPercent = node.SelectSingleNode("clouds").Attributes["all"].InnerText + node.SelectSingleNode("clouds").Attributes["unit"].InnerText;

           
            }

        }

Hiç yorum yok:

Yorum Gönder