Example #1
0
        public static GeoIpInformation FetchInformation()
        {
            using (var wc = new WebClient())
            {
                var xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(wc.DownloadString("https://freegeoip.net/xml/"));
                var rootElement = xmlDoc["Response"];
                var info = new GeoIpInformation();

                info.CountryCode = rootElement["CountryCode"].InnerText;
                info.CountryName = rootElement["CountryName"].InnerText;
                info.TimeZone = rootElement["TimeZone"].InnerText;
                info.Latitude = rootElement["Latitude"].InnerText;
                info.Longitude = rootElement["Longitude"].InnerText;

                return info;
            }
        }
Example #2
0
        public static GeoIpInformation FetchInformation()
        {
            using (var wc = new WebClient())
            {
                var xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(wc.DownloadString("https://freegeoip.net/xml/"));
                var rootElement = xmlDoc["Response"];
                var info        = new GeoIpInformation();

                info.CountryCode = rootElement["CountryCode"].InnerText;
                info.CountryName = rootElement["CountryName"].InnerText;
                info.TimeZone    = rootElement["TimeZone"].InnerText;
                info.Latitude    = rootElement["Latitude"].InnerText;
                info.Longitude   = rootElement["Longitude"].InnerText;

                return(info);
            }
        }