My goal is to remove placemarks in a kml file read with sharpkml and save the xml as new kml.
What I tried
- RemoveChildren -> Not found
- AddUpdate with DeleteCollection -> Not working
And
using SharpKml.Base;
using SharpKml.Dom;
using SharpKml.Engine;
TextReader i_test = File.OpenText(@"test.kml");
KmlFile k_test = KmlFile.Load(i_test);
Kml l_test = k_test.Root as Kml;
var serializer = new Serializer();
if (l_test != null)
{
foreach (var ort_u in l_test.Flatten().OfType<Placemark>())
{
Placemark p_u = ort_u;
foreach(var einh in ort_u.ExtendedData.Data)
{
if (einh.Name == "teststring")
{
var update = new Update();
update.AddUpdate(new DeleteCollection(){ p_u });
serializer.Serialize(l_test);
Console.WriteLine(serializer.Xml.Length);
}
}
}
}
None of them works.
How do I delete a Placemark using SharpKml and save the whole kml minus the placemark in a new file?