Read from XML
library("xml2")
library("XML")
data = read_xml('https://raw.githubusercontent.com/johnnyboy1287/booksxml/main/Lab8_XMLbooks.xml')
data <-xmlParse(data)
xmldf <- xmlToDataFrame(data)
Read from HTML
library(rvest)
htmlrawdata <- read_html("https://raw.githubusercontent.com/johnnyboy1287/htmlbooks/main/Lab8_books.html")
htmldata <- htmlrawdata %>% html_table(fill=TRUE)
htmldf <- as.data.frame(htmldata)
Read from JSON
library(rjson)
JSONdata<-fromJSON(file="https://raw.githubusercontent.com/johnnyboy1287/BooksJson/main/jsonBook.json")
jsondf <- as.data.frame(JSONdata)
Print all Data Frames
print(jsondf)
## Title Author Date.Published
## 1 Foundation Isaac Asimov 1942
## 2 A Short History of Nearly Everything Bill Bryson 2004
## 3 Dress Your Family in Corduroy and Denim David Sedaris 2005
## Genre
## 1 Sci-Fi
## 2 Informational
## 3 Humor
print(htmldf)
## Title Author Date.Published
## 1 Foundation Isaac Asimov 1942
## 2 A Short History of Nearly Everything Bill Bryson 2004
## 3 Dress Your Family in Corduroy and Denim David Sedaris 2005
## Genre
## 1 Sci-Fi
## 2 Informational
## 3 Humor
print(xmldf)
## Title Author DatePublished
## 1 Foundation Isaac Asimov 1942
## 2 A Short History of Nearly Everything Bill Bryson 2004
## 3 Dress Your Family in Corduroy and Denim David Sedaris 2005
## Genre
## 1 Sci-Fi
## 2 Informational
## 3 Humor
The data frames are more or less similar. Getting them to be so was
different for each file type.