2017-09-25 42 views
0

讀取XML我需要閱讀中的R中的R

http://forecast.weather.gov/MapClick.phplat=29.803&lon=-82.411&FcstType=digitalDWML

簡潔名=「表格數字」操作模式=「發育」 srsName =」從XML文檔的以下值WGS 1984「

在所有其他文章中,他們解釋過僅僅在開始時和結束時讀取帶有對象名稱的xml對象,其數據值位於中間。而在這裏對於我的問題,我需要閱讀的XML對象,它只有開頭,沒有XML結束的對象。

讓我知道這是可能的。任何幫助或輸入讚賞。

問候,
Mohanraj

+0

這是一個確切的副本。相同的座標。 –

+0

@ R.Schifini問題不重複。在所有已提供的鏈接上,解決方案不會讀取列concise-name,operational-mode和srsName的值。如果你運行的代碼,你會知道。 –

回答

0

這是我對這個任務兩種選擇:

library(XML) 
xmlfile <- xmlTreeParse("Your URL to the XML data") 
topxml <- xmlRoot(xmlfile) #function to access the top node of yopur file 
topxml <- xmlSApply(topxml,function(x) xmlSApply(x, xmlValue)) #To put your data in a data frame 
xml_df <- data.frame(t(topxml),row.names=NULL) 

您也可以選擇不完成所有前面的步驟,這是更復雜一點,並只是做到以下幾點:

url <- "Your URL to the XML data" 
data_df <- xmlToDataFrame(url) 
#or to list 
data <- xmlParse("Your URL to the XML data") 
xml_data <- xmlToList(data) 

學分由DataCamp

「讀入R數據」
+0

感謝您的信息。但是,它並沒有給我我期待的解決方案。不管怎樣,謝謝。 –