使用できます
temp <- getURL("http://api.worldbank.org/indicators")
temp <- xmlParse(temp)
xpathSApply(temp,"//wb:source") # example access data 1
xpathSApply(temp,"//wb:source[@id=2]") # example access data 2
xmlParse
または_xmlTreeParse(useInternalNodes=T)
この単純な構造を使用すると、次のようにデータフレームに変換できます
my.df<-xmlToDataFrame(temp)
またはリスト
my.list<-xmlToList(temp)
> my.list[[1]]
$name
[1] "Agricultural machinery, tractors"
$source
$source$text
[1] "World Development Indicators"
$source$.attrs
id
"2"
$sourceNote
[1] "Agricultural machinery refers to the number of wheel and crawler tractors (excluding garden tractors) in use in agriculture at the end of the calendar year specified or during the first quarter of the following year."
$sourceOrganization
[1] "Food and Agriculture Organization, electronic files and web site."
$topics
$topics$topic
$topics$topic$text
[1] "Agriculture & Rural Development "
$topics$topic$.attrs
id
"1"
$.attrs
id
"AG.AGR.TRAC.NO"