Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#Google-Earth
Hi all,
 
Is it possible to search the KML generated file by google earth which contains place marks?
 
For example:
 
I need the content of the sub element (Name) for the placemark element and its coordinates.
in other way (view to me every name of the place mark and its coordinates to make it searchable by C# application using the the content of the element (name) as a keyword)
 
This is a sample of the KML file:
 

 
 
&lt<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
	<name>default_myplaces_en_US.kml</name>
	<open>1</open>
	<Style id="sh_ylw-pushpin1">
		<IconStyle>
			<scale>1.3</scale>
			<Icon>
				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
			</Icon>
			<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
		</IconStyle>
	</Style>
	<Style id="sn_ylw-pushpin">
		<IconStyle>
			<scale>1.1</scale>
			<Icon>
				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
			</Icon>
			<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
		</IconStyle>
	</Style>
	<Style id="sn_ylw-pushpin1">
		<IconStyle>
			<scale>1.1</scale>
			<Icon>
				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
			</Icon>
			<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
		</IconStyle>
	</Style>
	<Style id="sh_ylw-pushpin0">
		<IconStyle>
			<scale>1.3</scale>
			<Icon>
				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
			</Icon>
			<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
		</IconStyle>
	</Style>
	<StyleMap id="msn_ylw-pushpin">
		<Pair>
			<key>normal</key>
			<styleUrl>#sn_ylw-pushpin1</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#sh_ylw-pushpin</styleUrl>
		</Pair>
	</StyleMap>
	<StyleMap id="msn_ylw-pushpin0">
		<Pair>
			<key>normal</key>
			<styleUrl>#sn_ylw-pushpin</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#sh_ylw-pushpin1</styleUrl>
		</Pair>
	</StyleMap>
	<StyleMap id="msn_ylw-pushpin1">
		<Pair>
			<key>normal</key>
			<styleUrl>#sn_ylw-pushpin0</styleUrl>
		</Pair>
		<Pair>
			<key>highlight</key>
			<styleUrl>#sh_ylw-pushpin0</styleUrl>
		</Pair>
	</StyleMap>
	<Style id="sn_ylw-pushpin0">
		<IconStyle>
			<scale>1.1</scale>
			<Icon>
				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
			</Icon>
			<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
		</IconStyle>
	</Style>
	<Style id="default_myplaces_style">
		<IconStyle>
			<Icon>
			</Icon>
		</IconStyle>
	</Style>
	<Style id="sh_ylw-pushpin">
		<IconStyle>
			<scale>1.3</scale>
			<Icon>
				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
			</Icon>
			<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
		</IconStyle>
	</Style>
	<Folder>
		<name>My Places</name>
		<open>1</open>
		<Style>
			<ListStyle>
				<listItemType>check</listItemType>
				<ItemIcon>
					<state>open</state>
					<href>C:/Program Files (x86)/Google/Google Earth/res/mysavedplaces_open.png</href>
				</ItemIcon>
				<ItemIcon>
					<state>closed</state>
					<href>C:/Program Files (x86)/Google/Google Earth/res/mysavedplaces_closed.png</href>
				</ItemIcon>
				<bgColor>00ffffff</bgColor>
				<maxSnippetLines>2</maxSnippetLines>
			</ListStyle>
		</Style>
		<Placemark>
			<name>1st Placemark</name>
			<LookAt>
				<longitude>-88.6053771201891</longitude>
				<latitude>32.28430709663048</latitude>
				<altitude>0</altitude>
				<range>250.1819494419393</range>
				<tilt>0</tilt>
				<heading>2.055254877575029</heading>
				<altitudeMode>relativeToGround</altitudeMode>
			</LookAt>
			<styleUrl>#msn_ylw-pushpin0</styleUrl>
			<Point>
				<coordinates>-88.6053771201891,32.28430709663048,0</coordinates>
			</Point>
		</Placemark>
		<Placemark>
			<name>2nd Placemark</name>
			<LookAt>
				<longitude>-88.61764632679935</longitude>
				<latitude>32.27910235483834</latitude>
				<altitude>0</altitude>
				<range>1128.948498702121</range>
				<tilt>0</tilt>
				<heading>2.048701985830222</heading>
				<altitudeMode>relativeToGround</altitudeMode>
			</LookAt>
			<styleUrl>#msn_ylw-pushpin1</styleUrl>
			<Point>
				<coordinates>-88.61764632679935,32.27910235483834,0</coordinates>
			</Point>
		</Placemark>
		<Placemark>
			<name>3rd Placemark</name>
			<LookAt>
				<longitude>-88.60302684575669</longitude>
				<latitude>32.26715342195568</latitude>
				<altitude>0</altitude>
				<range>2380.764313737851</range>
				<tilt>0</tilt>
				<heading>2.056509492270209</heading>
				<altitudeMode>relativeToGround</altitudeMode>
			</LookAt>
			<styleUrl>#msn_ylw-pushpin</styleUrl>
			<Point>
				<coordinates>-88.60302684575669,32.26715342195568,0</coordinates>
			</Point>
		</Placemark>
	</Folder>
</Document>
</kml>
 

Posted 15-Dec-12 23:10pm
M.S.S.E400
Edited 15-Dec-12 23:13pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

KML is XML, so you can use xpath[^]
  Permalink  
Comments
M.S.S.E at 17-Dec-12 3:35am
   
Thank you, this one helped: http://www.codeproject.com/Articles/9494/Manipulate-XML-data-with-XPath-and-XmlDocument-C

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 9,225
1 OriginalGriff 5,395
2 Peter Leow 4,100
3 Maciej Los 3,540
4 Abhinav S 3,333


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 16 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid