コード例 #1
0
        public WikiMapiaPlace GetByID(int id)
        {
            string key = GetKey();

            string func = String.Format(FunctionPlaceGetByID, id);
            string url  = string.Format(Format, key, func, "en", "", "");
            string path = String.Format(PathFormatByID, id);

            var     xmlDoc   = LoadWikiDocument(url, path);
            XmlNode mainNode = xmlDoc.SelectSingleNode("wm");

            var p = ParseWikiPlace(mainNode);

            RamCache.Add(p.Id, p);

            return(p);
        }
コード例 #2
0
        void ParseXmlDocument(XmlDocument xmlDoc, out int elementsFound)
        {
            XmlNode mainNode = xmlDoc.SelectSingleNode("wm");
            XmlNode places   = mainNode.SelectSingleNode("places");

            string lang = mainNode.SelectSingleNode("language").InnerText;

            elementsFound = int.Parse(mainNode.SelectSingleNode("found").InnerText);             // TryParse
            int pageNumber    = int.Parse(mainNode.SelectSingleNode("page").InnerText);
            int elementsCount = int.Parse(mainNode.SelectSingleNode("count").InnerText);

            foreach (XmlNode place in places)
            {
                var p = ParseWikiPlace(place);

                if (!RamCache.ContainsKey(p.Id))
                {
                    RamCache.Add(p.Id, p);
                }
            }
        }