示例#1
0
        private static List <Scenic> ReadXml()
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(@"../../" + "input/data_with_location_2.xml");
            XmlNode       scenicNode = xmlDoc.SelectSingleNode("scenic");
            XmlNodeList   items      = scenicNode.ChildNodes;
            List <Scenic> scenicList = new List <Scenic>();

            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.Title = scenicName;
                scenic.Lat   = scenicLat;
                scenic.Lng   = scenicLng;
                scenicList.Add(scenic);
            }
            Console.WriteLine("data_with_location_2: " + scenicList.Count);
            streamWriter.WriteLine("data_with_location_2: " + scenicList.Count);
            return(scenicList);
        }
示例#2
0
        private static List<Scenic> ReadXml()
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load(@"../../" + "input/data_with_location_2.xml");
            XmlNode scenicNode = xmlDoc.SelectSingleNode("scenic");
            XmlNodeList items = scenicNode.ChildNodes;
            List<Scenic> scenicList = new List<Scenic>();
            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.Title = scenicName;
                scenic.Lat = scenicLat;
                scenic.Lng = scenicLng;
                scenicList.Add(scenic);
            }
            Console.WriteLine("data_with_location_2: " + scenicList.Count);
            streamWriter.WriteLine("data_with_location_2: " + scenicList.Count);
            return scenicList;
        }