Free Support Forum - aspose.com

How read google kml file?

doc.zip (1.2 KB)
i try open my kml file but its show error
var layer = Drivers.Kml.OpenLayer(“doc.kml”, new KmlOptions() { });
var featureAtIndex1 = layer[0];

Hi, @mesteruh

Please consider the below code to read KML file

        // put to a 'using' statement to manage the resources more optimal
        using (var layer = Drivers.Kml.OpenLayer(@"doc.kml", new KmlOptions() { }))
        {
            // read
            foreach (var feature in layer)
            {
                // print all values
                object[] valuesDump = feature.GetValuesDump();
                for (int i = 0; i < valuesDump.Length; i++)
                {
                    Console.Write(valuesDump[i]);
                    Console.Write(",");
                }

                // split
                Console.WriteLine();
            }
        } 

Thank you for sharing the issue details. Your approach is correct too, but it threw an exception. We created a ticket GISNET- 595 to investigate this case. We will notify you here as we will have progress with it.