Exemple #1
0
        public static void ReadXml(string filename)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(@"../../" + "DataScraperWorks/" + filename);
            XmlNode     scenicNode = xmlDoc.SelectSingleNode("scenic");
            XmlNodeList items      = scenicNode.ChildNodes;

            foreach (XmlNode item in items)
            {
                XmlNode scenicNameNode = item.SelectSingleNode("scenicname");
                string  scenicName     = scenicNameNode != null ? scenicNameNode.InnerText : "null";
                XmlNode scenicLngNode  = item.SelectSingleNode("lng");
                string  scenicLng      = scenicLngNode != null ? scenicLngNode.InnerText : "null";
                XmlNode scenicLatNode  = item.SelectSingleNode("lat");
                string  scenicLat      = scenicLatNode != null ? scenicLatNode.InnerText : "null";
                XmlNode scenicComeNode = item.SelectSingleNode("from");
                string  scenicComeFrom = scenicComeNode != null ? scenicComeNode.InnerText : "null";
                Scenic  scenic         = new Scenic();
                scenic.scenicName = scenicName;
                scenic.scenicLat  = scenicLat;
                scenic.scenicLng  = scenicLng;
                scenic.comeFrom   = scenicComeFrom;
                scenicList.Add(scenic);
            }
            Console.WriteLine("scenicList: " + scenicList.Count);
        }
Exemple #2
0
        public int CompareTo(object obj)
        {
            int result;

            try
            {
                Scenic scenic = obj as Scenic;
                result = this.scenicName.CompareTo(scenic.scenicName);
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
                throw new Exception(e.Message);
            }
        }