public void TestSerialize() { const string Expected = "<kml xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns=\"http://www.opengis.net/kml/2.2\">" + "<Document>" + "<atom:author>" + "<atom:name>Name</atom:name>" + "</atom:author>" + "<atom:link href=\"http://www.example.com/\" />" + "</Document>" + "</kml>"; Document document = new Document(); document.AtomAuthor = new Author { Name = "Name" }; document.AtomLink = new SharpKml.Dom.Atom.Link { Href = new Uri("http://www.example.com") }; Kml root = new Kml(); root.AddNamespacePrefix(KmlNamespaces.AtomPrefix, KmlNamespaces.AtomNamespace); root.Feature = document; Serializer serializer = new Serializer(); serializer.SerializeRaw(root); Assert.That(serializer.Xml, Is.EqualTo(Expected)); }
public override void saveKmlDocument(Document kmlDoc) { // This allows us to save and Element easily. var kml = new Kml(); kml.AddNamespacePrefix(KmlNamespaces.GX22Prefix, KmlNamespaces.GX22Namespace); kml.Feature = kmlDoc; KmlFile kmlF = KmlFile.Create(kml, false); kmlF.Save(@"mykmlFile.kml"); }