Reading in XML/KML files using C#

后端 未结 5 1374
遥遥无期
遥遥无期 2021-02-03 11:28

I\'m trying to import the kml xml Google earth file into an application, but i can\'t seem to get the xDocument syntax right in order to do what i want, i\'m wondering if anyone

5条回答
  •  醉话见心
    2021-02-03 11:54

    var xDoc = XDocument.Load("a.xml");
    XNamespace ns = "http://earth.google.com/kml/2.2";
    
    var placemarks = xDoc.Descendants(ns+"Placemark")
                        .Select(p => new
                        {
                            Name = p.Element(ns+"name").Value,
                            Desc = p.Element(ns+"description").Value
                        })
                        .ToList();
    

提交回复
热议问题