Can you help me parse this kml in c#?

i got this KML from a location weeb service and i need to parse it. i need to get all the PLACEMARK tags read i need just the name latitude and longitude from them. Thx for any help.

<?xml version="1.0" encoding="UTF-8" ?> 
 <kml xmlns="http://www.opengis.net/kml/2.2">
 <Document>
  <name>Lociraj.net (C) 2010</name> 
 <StyleMap id="highlighting">
 <Pair>
  <key>normal</key> 
  <styleUrl>#normalState</styleUrl> 
  </Pair>
 <Pair>
  <key>highlight</key> 
  <styleUrl>#highlightedState</styleUrl> 
  </Pair>
  </StyleMap>
 <Style id="highlightedState">
 <IconStyle>
  <scale>1.1</scale> 
 <Icon>
  <href>http://maps.google.com/mapfiles/kml/pal3/icon55.png</href> 
  </Icon>
  </IconStyle>
 <LabelStyle>
  <scale>1.1</scale> 
  </LabelStyle>
  </Style>
 <Style id="normalState">
 <IconStyle>
 <Icon>
  <href>http://maps.google.com/mapfiles/kml/pal3/icon63.png</href> 
  </Icon>
  </IconStyle>
  </Style>
 <Placemark>
  <name>Vaša lokacija</name> 
  <description /> 
 <LookAt>
  <longitude>15.976903</longitude> 
  <latitude>45.813182</latitude> 
  <altitude>0</altitude> 
  <range>500</range> 
  </LookAt>
 <Style>
 <IconStyle>
 <Icon>
  <href>http://lociraj.net/img/icon_map_your_location.png</href> 
  </Icon>
  </IconStyle>
  </Style>
 <Point>
  <coordinates>15.976903,45.813182,0</coordinates> 
  </Point>
  </Placemark>
 <Folder>
  <name>Bankomati</name> 
 <Placemark>
  <name>Raiffeisen</name> 
 <description>
 <![CDATA[ Ilica 1a, Zagreb<br><br>Raiffeisenbank<br>
<b>Udaljenost:</b> 65m<br>

  ]]> 
  </description>
 <LookAt>
  <longitude>15.9761</longitude> 
  <latitude>45.813</latitude> 
  <altitude>0</altitude> 
  <range>500</range> 
  </LookAt>
 <Style>
 <IconStyle>
 <Icon>
  <href>http://lociraj.net/img/icon_map_atm.png</href> 
  </Icon>
  </IconStyle>
  </Style>
 <ExtendedData xmlns:l="http://lociraj.net">
  <l:categoryID>1</l:categoryID> 
  <l:entryID>1782</l:entryID> 
  </ExtendedData>
 <Point>
  <coordinates>15.9761,45.813,0</coordinates> 
  </Point>
  </Placemark>
 <Placemark>
  <name>PBZ</name> 
 <description>
 <![CDATA[ Trg bana J. Jelačića 7, Zagreb<br><br><br>
<b>Udaljenost:</b> 66m<br>

  ]]> 
  </description>
 <LookAt>
  <longitude>15.9777218535</longitude> 
  <latitude>45.8133623448</latitude> 
  <altitude>0</altitude> 
  <range>500</range> 
  </LookAt>
 <Style>
 <IconStyle>
 <Icon>
  <href>http://lociraj.net/img/icon_map_atm.png</href> 
  </Icon>
  </IconStyle>
  </Style>
 <ExtendedData xmlns:l="http://lociraj.net">
  <l:categoryID>1</l:categoryID> 
  <l:entryID>921</l:entryID> 
  </ExtendedData>
 <Point>
  <coordinates>15.9777218535,45.8133623448,0</coordinates> 
  </Point>
  </Placemark>
 <Placemark>
  <name>Erste</name> 
 <description>
 <![CDATA[ Ilica bb, Zagreb<br><br>ZET okretište - Črnomerec<br>
<b>Udaljenost:</b> 68m<br>

  ]]> 
  </description>
 <LookAt>
 <longitude>15.976051</longitude> 
  <latitude>45.81303</latitude> 
  <altitude>0</altitude> 
  <range>500</range> 
  </LookAt>
 <Style>
 <IconStyle>
 <Icon>
  <href>http://lociraj.net/img/icon_map_atm.png</href> 
  </Icon>
  </IconStyle>
  </Style>
 <ExtendedData xmlns:l="http://lociraj.net">
  <l:categoryID>1</l:categoryID> 
  <l:entryID>309</l:entryID> 
  </ExtendedData>
 <Point>
  <coordinates>15.976051,45.81303,0</coordinates> 
  </Point>
  </Placemark>
 <Placemark>
  <name>Erste</name> 
 <description>
 <![CDATA[ Ilica 1, Zagreb<br><br>Prolaz - Neboder<br>
<b>Udaljenost:</b> 68m<br>

  ]]> 
  </description>
 <LookAt>
  <longitude>15.976051</longitude> 
  <latitude>45.81303</latitude> 
  <altitude>0</altitude> 
  <range>500</range> 
  </LookAt>
 <Style>
<IconStyle>
 <Icon>
  <href>http://lociraj.net/img/icon_map_atm.png</href> 
  </Icon>
  </IconStyle>
  </Style>
 <ExtendedData xmlns:l="http://lociraj.net">
  <l:categoryID>1</l:categoryID> 
  <l:entryID>300</l:entryID> 
  </ExtendedData>
 <Point>
  <coordinates>15.976051,45.81303,0</coordinates> 
  </Point>
  </Placemark>
 <Placemark>
  <name>ZaBa</name> 
 <description>
<![CDATA[ Ilica bb, Zagreb<br><br>ZET okretište - Črnomerec<br>
<b>Udaljenost:</b> 68m<br>

  ]]> 
  </description>
 <LookAt>
  <longitude>15.976051</longitude> 
  <latitude>45.81303</latitude> 
  <altitude>0</altitude> 
  <range>500</range> 
  </LookAt>
 <Style>
 <IconStyle>
 <Icon>
  <href>http://lociraj.net/img/icon_map_atm.png</href> 
  </Icon>
  </IconStyle>
  </Style>
 <ExtendedData xmlns:l="http://lociraj.net">
  <l:categoryID>1</l:categoryID> 
  <l:entryID>1519</l:entryID> 
  </ExtendedData>
 <Point>
  <coordinates>15.976051,45.81303,0</coordinates> 
  </Point>
  </Placemark>
  </Folder>
  </Document>
  <kml>

Can you help me parse this

Answers


XDocument xDoc = XDocument.Load(....);
XNamespace ns = "http://www.opengis.net/kml/2.2";

var placemarks = xDoc
            .Descendants(ns + "Placemark")
            .Select(p => new
            {
                Name = p.Element(ns+"name").Value,
                Longitude = p.Element(ns+"LookAt").Element(ns+"longitude").Value,
                Latitude = p.Element(ns+"LookAt").Element(ns+"latitude").Value,
            })
            .ToArray();

Need Your Help

Why is my python code bogging down my server?

python linux cpu syslog

I am new to python and am trying to code my own syslog program. I have tested this on my own machine, and it works fine, I don't notice anything. Now when I put it on my Ubuntu VM it spikes the CPU

SQL Server error “Procedure expects parameter”

c# sql sql-server

I'm writing a login script. But when I want to check if user already exist the error: