Exploratory Community

How to import XML data

#1

We currently don’t support XML data out of the box, but you can write a R script to read the XML data.

Here’s an example R script:

library(XML)
library(RCurl)

url <- "https://feeds.capitalbikeshare.com/stations/stations.xml"
df_station <- url %>% 
  RCurl::getURL() %>% 
  XML::xmlParse() %>% 
  XML::xmlToDataFrame(., stringsAsFactors = FALSE)
  1. Select ‘R Script’ from the data frame menu.

  2. Past the above script.

And it looks like this.

Note that you will also need to install ‘RCurl’ package in order to run the above script. Here’s how to install R package.

https://docs.exploratory.io/r_package.html

1 Like