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 could suggest a way to read in the kml xml file.
I understand the basics of xml import but can't get anything working with xDocument and Linq, ideally i'd like to get each Placemark as an object and add them to my Entity Framework driven db. Any suggestions as to how i should do this would be great, as i'm just starting out with Linq and could do with some pointers. The xml is laid out as below
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<Placemark>
<name>XXX</name>
<description>XXX</description>
<styleUrl>XXX</styleUrl>
<Point>
<coordinates>XXX</coordinates>
</Point>
</Placemark>
<Placemark>
<name>XXX</name>
<description>XXX</description>
<styleUrl>XXX</styleUrl>
<Point>
<coordinates>XXX</coordinates>
</Point>
</Placemark>
</Document>
</kml>
I used SharmpKml and its documentation to extract information from KML file.
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:
Using namespaces:
My guess is that you've forgotten to use the namespace in your LINQ to XML queries. It's easy enough to extract the data from this:
If that doesn't help, please post a complete example of what you've tried, and what went wrong.