Reading in XML/KML files using C#

后端 未结 5 1373
遥遥无期
遥遥无期 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:53

    You didn't include any code, but I would guess that you forgot to include your namespace when referencing things. Here is an example.

    Basic access:

    var placemarks = xdoc.Element("kml").Element("Document").Elements("Placemark");
    

    Using namespaces:

    var ns = XNamespace.Get("http://earth.google.com/kml/2.2");
    var placemarks = xdoc.Element(ns + "kml").Element(ns + "Document").Elements(ns + "Placemark");
    

提交回复
热议问题