I've been trying all day to write some code that will read the data from a kml containing a google earth polygon and extract the name and the coordinates and store everything as latitudes and longitudes. I already made a user form that allows the user to browse for the kml and then run the extraction code. Unfortunately the extraction doesn't work. I'm very new to VB but I did take three semesters of C++ in college, it's been close to a year since then though. Here's what I have but I understand that I could also be completely wrong..
Function X(InputFile As String, Text As String)
Dim textReader As New Xml.XmlTextReader(InputFile)
Dim lastElementName As String = ""
While textReader.Read()
Select Case textReader.NodeType
Case Xml.XmlNodeType.Element
lastElementName = textReader.Name
Case Xml.XmlNodeType.Text
MsgBox(lastElementName & ": " & textReader.Value)
End Select
Console.WriteLine()
End While
Basic KML Example:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>The Pentagon</name>
<Polygon>
<tessellate>1</tessellate>
<outerBoundaryIs>
<LinearRing>
<coordinates>
-77.05668055019126,38.87154239798456
-77.05542625960818,38.87167890344077
-77.05485125901024,38.87076535397792
-77.05577677433152,38.87008686581446
-77.05691162017543,38.87054446963351
-77.05668055019126,38.87154239798456
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</kml>