在VB.net中解析Google GeoCode xml

时间:2013-05-14 18:50:28

标签: vb.net google-maps geolocation

好的,所以我得到了我的小块代码,并且在我发送了lat和long之后,将谷歌从谷歌带回我的位置。我现在需要做的就是从中获取一行。 从第二个结果集我需要得到formatted_address。 从来没有在vb.net中进行任何xml解析,所以我迷路了。

Dim webClient As New System.Net.WebClient
    Dim result As String = webClient.DownloadString("http://maps.googleapis.com/maps/api/geocode/xml?latlng=44.46944050638752,-88.08779155546756&sensor=false")
    Return result

之后我迷路了!

1 个答案:

答案 0 :(得分:2)

如果有人需要知道。我想到了。这是我做的:

Dim myAddress As String = "Nothing"
    Dim webClient As New System.Net.WebClient
    Dim result As String = webClient.DownloadString("http://maps.googleapis.com/maps/api/geocode/xml?latlng=lat,long&sensor=false")

    Dim xmlDoc As New XmlDocument()
    xmlDoc.LoadXml(result)
    Dim m_nodelist As XmlNodeList

    m_nodelist = xmlDoc.SelectNodes("/GeocodeResponse/result/formatted_address")


    myAddress = m_nodelist(1).InnerText

    result = myAddress