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; } }
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); } }