Пример #1
0
        static void Main(string[] args)
        {
            XmlReaderSettings settingsR = new XmlReaderSettings();

            settingsR.IgnoreComments   = true;
            settingsR.IgnoreWhitespace = true;
            Placemarks placemarks = new Placemarks();

            using (XmlReader reader = XmlReader.Create(@"C:\temp\SS_Merged2015.kml", settingsR))
            {
                while (reader.Read())
                {
                    if (reader.Name == Placemarks.XmlName)
                    {
                        placemarks.ReadXml(reader);
                    }
                }
            }
            int photocount = 0;

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\temp\SS_Merged2015.csv"))
                foreach (Placemark pm in placemarks.collection)
                {
                    string content = "";
                    content += pm.Name;
                    if (pm.Description.Photos != null)
                    {
                        foreach (Photo photo in pm.Description.Photos.collection)
                        {
                            photocount += 1;
                            content    += ",";
                            content    += photo.pn;
                        }
                    }

                    file.WriteLine(content);
                }
            Console.WriteLine(placemarks.collection.Count() + "in total!");
            Console.WriteLine("Photo Number " + photocount + " in total!");
            Console.Read();
        }
Пример #2
0
        static void Main(string[] args)
        {
            XmlReaderSettings settingsR= new XmlReaderSettings();
            settingsR.IgnoreComments = true;
            settingsR.IgnoreWhitespace = true;
            Placemarks placemarks = new Placemarks();
            using (XmlReader reader = XmlReader.Create(@"C:\temp\SS_Merged2015.kml", settingsR))
            {

                while(reader.Read())
                {
                    if (reader.Name==Placemarks.XmlName)
                    {
                        placemarks.ReadXml(reader);
                    }
                }
            }
            int photocount =0;
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\temp\SS_Merged2015.csv"))
            foreach (Placemark pm in placemarks.collection)
            {

                string content = "";
                content += pm.Name;
                if (pm.Description.Photos != null)
                {
                foreach(Photo photo in pm.Description.Photos.collection)
                {
                    photocount += 1;
                    content += ",";
                    content += photo.pn;
                }
                }

                file.WriteLine(content);
            }
            Console.WriteLine(placemarks.collection.Count() + "in total!");
            Console.WriteLine("Photo Number " + photocount + " in total!");
            Console.Read();
        }