2009-11-18 137 views
1

我從我的SQL查詢(名稱,描述,緯度,經度)中獲取我的信息,但我有問題將其轉換爲GeoRSS的正確格式,以便它可以被我的虛擬地球地圖。 FOR XML AUTO並沒有給我想要的東西,我似乎也找不到任何如何將SQL查詢的輸出提取到GeoRSS的例子。將SQL查詢結果輸出到GeoRSS

這裏是的GeoRSS格式的樣本,我正在尋找:

<channel> 
    <title>Reported Road Hazards</title> 
    <link/> 
    <description>Road hazards reported to the city</description> 
<item> 
     <title>Traffic Light</title> 
     <description>Traffic light on north west corner out</description> 
     <geo:lat>43.64887</geo:lat> 
     <geo:long>-79.385362</geo:long> 
    </item> 
</channel> 

回答

1

我已經得到通過SQL我所需的輸出。

With XMLNAMESPACES ('http://www.w3.org/2003/01/geo/wqs84_pos#' as geo) 
Select Name as title, [Description], Lat as 'geo:lat', Long as 'geo:long' 
From myTable 
FOR XML PATH ('item'), ROOT('rss') 

這一基本格局將由服務,如Bing地圖,谷歌地圖等給你的GeoRSS格式消費XML ....