示例#1
0
        private void GetNodes()
        {
            int id;
            try
            {
                id = int.Parse(this.txtGenonameId.Text);
            }
            catch { return; }

            try
            {
                var g = GeoNamesOrgWebservice.Get(id);
                var sg = new SimpleGeoName(g);
                
                GetChildren(sg, g);

                var xml = XmlHelper.ToXml<SimpleGeoName>(sg);
                File.WriteAllText(@"c:\output.xml", xml);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void GetChildren(SimpleGeoName sg, Geoname g)
        {
            Path.Push(sg);
            CurrentLevel--;
            try
            {
                foreach (var n in g.Children(GeoNamesDataStyle.Full))
                {
                    ItemCount++;
                    UpdateCounterUI();

                    var nsg = new SimpleGeoName(n);
                    sg.Children.Add(nsg);
                    if (CurrentLevel >= 0)
                    {
                        GetChildren(nsg, n);
                    }
                }
            }
            catch{}
            CurrentLevel++;
            Path.Pop();
        }