谷歌地球xml檔案解析

2021-06-18 06:02:18 字數 1233 閱讀 3612

google earth 和google map的區別:

google earth和google map用的實際上是同一種資料,只不過是表現形式不一樣而已。google earth採用的是google在04年收購keyhole的 kml(keyhole markup language)標記語言來描述和儲存地理資訊,而google map則是採用html頁面和的形式來表現資料的。如圖1-1所示,我們可以看到其實google earth也是像google map那樣當個瀏覽器,只不過google map瀏覽的網頁是html格式的檔案,而google earth瀏覽的是kml的壓縮格式kmz格式的檔案,它們都是通過網路傳輸的方式傳給使用者的。因為採用的是ajax技術傳輸的地圖,所以使用者可以方便的再地圖上放大,縮小,移動而不用再次傳輸資料,這就是所謂的非同步,它極大地提高了使用者的體驗性。不像同步傳輸,每次設定都得再從網上傳輸資料。但google earth和google map都有乙個共同的缺點它們的內容都是靜態的,或者說是相對靜態的,不會實時更新資料,就像world wind那樣可以研究颶風或是**對整個區域的影響。

kml語言:

kml是一種在earth browser(比如google earth,google maps,google maps for mobile)用於顯示地理資料的檔案格式。

kml檔案採用xml檔案的語法和檔案結構,該檔案基於tag(標籤)的表示式,tag以開頭,結尾,中間是tag的值。kml檔案時很多tag結構的集合。tag之間的關係主要包含並列和包含兩種方式。

google earth中的tag具有明顯的層次結構,最上層的是kml,用來表明該檔案時乙個kml檔案,kml檔案的下層主要包括folder和document,其中folder用來建立資料夾,document用來建立乙個目錄。folder和document的下層包含很多tag,其中最重要的是placemark。

placemark下層的tag列表:

kml示例:

<?xml version="1.0" standalone="yes"?>

wuhan

qingchuangqiao

wuhan,china

114.2797000

30.565800000

0114.2797000,30.5658000,0

建立xml檔案 解析xml檔案

import codecs import xml.dom.minidom doc xml.dom.minidom.document print doc root doc.createelement booklist print u 新增的xml標籤為 root.tagname root.setatt...

解析XML檔案

sax解析xml 得到saxparse ctory saxparse ctory saxparse ctory saxparse ctory.newinstance 得到saxparser saxparser saxparser saxparse ctory.newsaxparser 得到xmlre...

XML檔案解析

xml是可擴充套件標記語言,用來傳輸和儲存資料。xml文件必須包含根元素,該元素是所有其他元素的父元素。xml文件中的元素形成了樹形結構。xml有以下特點 建立名稱是 textfile1.txt 的文件,設定屬性 複製到輸出目錄 如果較新則複製 在工程執行時,會自動將該txt檔案複製到bin下面。2...