xml.url<-"https://raw.githubusercontent.com/kglan/MSDS/main/DATA607/Working%20with%20XML%20and%20JSON%20files/favbooks.xml"
xData <- getURL(xml.url)
XML_df <- xmlToDataFrame(xData)
XML_df
## title Year Author Publisher
## 1 R for Data Science 2017 Garrett Grolemund, Hadley Wickham O'Reilly Media
## 2 Think Python 2002 Allen B. Downey O'Reilly Media
## 3 High-Frequency Trading 2013 Irene Aldridge Wiley
html.url <- "https://raw.githubusercontent.com/kglan/MSDS/main/DATA607/Working%20with%20XML%20and%20JSON%20files/favbooks.html"
hData <- read_html(html.url)
HTML_df <- hData%>%
html_nodes("table")%>%
html_table()%>% .[[1]]
HTML_df
## # A tibble: 3 × 4
## Title Year Author Publisher
## <chr> <int> <chr> <chr>
## 1 R for Data Science 2017 Garrett Grolemund, Hadley Wickham O'Reilly Media
## 2 Think Python 2002 Allen B. Downey O'Reilly Media
## 3 High-Frequency Trading 2013 Irene Aldridge Wiley
#Read JSON file
json.url<- "https://raw.githubusercontent.com/kglan/MSDS/main/DATA607/Working%20with%20XML%20and%20JSON%20files/favbooks.json"
jData <- fromJSON(file=json.url)
#jData <- (fromJSON(paste(readLines(json.url))))
JSON_df <- as.data.frame(jData)
JSON_df
## Title Year Author Publisher
## 1 R or Data Science 2017 Garrett Grolemund, Hadley Wickham O'Reilly Media
## 2 Think Python 2002 Allen B. Downey O'Reilly Media
## 3 High-Frequency Trading 2013 Irene Aldridge Wiley
All the data frames can be input the same if they are formatted and loaded properly