public static CountryGeography Create(XmlElement element) { CountryGeography country = new CountryGeography(); country.Name = element.SelectSingleNode("name").InnerText; country.Description = element.SelectSingleNode("description").InnerText; var lookatNode = element.SelectSingleNode("LookAt"); country.CentralLatitude = Double.Parse(lookatNode.SelectSingleNode("latitude").InnerText); country.CentralLongitude = Double.Parse(lookatNode.SelectSingleNode("longitude").InnerText); var boundaryRingCoordinates = element.SelectNodes("MultiGeometry/Polygon/outerBoundaryIs/LinearRing"); foreach (var boundary in boundaryRingCoordinates) { PolygonBoundary landBlock = new PolygonBoundary( ((XmlElement)boundary).SelectSingleNode("coordinates").InnerText); country.LandBlocks.Add(landBlock); } country.UpdateLatLongs(); country.XmlElement = element; return(country); }
private void ParseCountries(XmlDocument doc) { var nameNodes = doc.SelectNodes("//Document/Placemark/name"); var placemarkNodes = doc.SelectNodes("//Document/Placemark"); if (placemarkNodes == null) { return; } foreach (var node in placemarkNodes) { XmlElement element = (XmlElement)node; CountryGeography country = CountryGeography.Create(element); _countries.Add(country.Name, country); } }