我從Google地球專業版導出了kml文件,包含37個文件夾,每個文件夾包含「次要」文件夾數量,共計「次要」文件夾數量爲168個,每個「未成年人「有3個地標。在KML文件中添加標籤使用R
我製作了HTML代碼,我用R做了它,並且想要將這個kml文件導入到R中,並將這個HTML代碼放到每個「次要」文件夾的第一個「地標」中,這個HTML代碼不是常量,它有像這個代碼中的表中的值這樣的變量,並且這個變量將從我爲這個「次要」文件夾製作的數據框中附加,當我編輯這個HTML代碼時,我會將它放入第一個「地標」 「次要」文件夾,等等其他「次要」文件夾。
R中是否有任何功能可以將此代碼添加到kml文件中?
這裏的 「說明」 中R.代碼
URL <- paste("file:///C:/Users/pc/Downloads/Googletraffic/Tazbet/Autostrad;Helwan To Da2ery/",FileName,sep = "")
library(XML)
top = newXMLNode("description")
table = newXMLNode("table ", attrs = c(width = 300, border = 1), parent = top)
tbody <- newXMLNode("tbody",parent = tr)
tr <- newXMLNode("tr",parent = table)
th <- newXMLNode("th",attrs = c(scope = "col"),scope1 = max(Bey2ollak$V3),parent = tr)
th <- newXMLNode("th",attrs = c(scope = "col"),scope1 = "MD",parent = tr)
th <- newXMLNode("th",attrs = c(scope = "col"),scope1 = "PM",parent = tr)
tr <- newXMLNode("tr",parent = table)
th <- newXMLNode("th",attrs = c(scope = "col"),scope1 = max(Bey2ollak$V3),parent = tr)
th <- newXMLNode("th",attrs = c(scope = "col"),scope1 = "MD",parent = tr)
th <- newXMLNode("th",attrs = c(scope = "col"),scope1 = "PM",parent = tr)
tr <- newXMLNode("tr",parent = table)
th <- newXMLNode("th",attrs = c(scope = "col"),scope1 = max(Bey2ollak$V3),parent = tr)
th <- newXMLNode("th",attrs = c(scope = "col"),scope1 = "MD",parent = tr)
th <- newXMLNode("th",attrs = c(scope = "col"),scope1 = "PM",parent = tr)
th <- newXMLNode("img",attrs = c(src = URL,width = "700",height= "777",alt=""),parent =top)
top
這裏是控制檯輸出
<description>
<table width="300" border="1">
<tr>
<th scope="col">5</th>
<th scope="col">MD</th>
<th scope="col">PM</th>
</tr>
<tr>
<th scope="col">5</th>
<th scope="col">MD</th>
<th scope="col">PM</th>
</tr>
<tr>
<th scope="col">5</th>
<th scope="col">MD</th>
<th scope="col">PM</th>
</tr>
</table >
<img src="file:///C:/Users/pc/Downloads/Googletraffic/Tazbet/Autostrad;Helwan To Da2ery/Spiral.jpg " width="700" height="777" alt=""/>
</description>
here's我的KML文件
「XML」包允許添加,刪除和編輯標籤,標籤屬性和標籤值。 – hrbrmstr
XML庫可能是你想要的。看到這個帖子 - > http://stackoverflow.com/questions/23505906/use-r-to-read-a-xml-file-select-few-nodes-and-write-it-back-to-another-xml – JMT2080AD
@hrbrmstr,我正在閱讀手冊,我正在尋找一個功能,在特定的地方添加標籤,如果您找到答案,請幫助我。 –