我試圖從KML文件中的地標中提取多邊形。到目前爲止好:如何獲取Linq中XML的XElement的.InnerText值?
Imports <xmlns:g='http://earth.google.com/kml/2.0'>
Imports System.Xml.Linq
Partial Class Test_ImportPolygons
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Kml As XDocument = XDocument.Load(Server.MapPath("../kmlimport/ga.kml"))
For Each Placemark As XElement In Kml.<g:Document>.<g:Folder>.<g:Placemark>
Dim Name As String = Placemark.<g:name>.Value
...
Next
End Sub
End Class
我想捕捉整個<polygon>...</polygon>
塊作爲一個字符串。我想是這樣的(其中...是以上):
Dim Polygon as String = Placemark.<g:Polygon>.InnerText
不過的XElement對象不具有InnerText屬性,或任何等效據我可以告訴。我如何獲取定義XElement的原始XML?
是的,但是這給了我整個地標節點,而我只是想要多邊形。我錯過的是`地標。`是XElements的集合,而不是單個XElement。 –
2008-09-30 15:17:50