I want to make a shiny app which uploads a html file which has xml in it. But when I upload this html file, it gives me an error
no applicable method for 'read_xml' applied to an object of class "data.frame"
The file can be read when run in a normal condition(non shiny app condition). My code is as follows:
library(shiny)
library(rvest)
ui <- fluidPage(
fileInput(
inputId = "file_input",
"Upload file",
multiple = TRUE,
accept = ".html"
),
tableOutput("table")
)
server <- function(input, output) {
getData <- reactive({
inFile <- input$file_input
if (is.null(inFile)) {
return(NULL)
} else {
inputdata <- read_html(inFile)
}
})
output$table <- renderTable({
getData()
})
}
shinyApp(ui = ui, server = server)
Reading answers online, I also tried to add a html_session
for
the same.
server <- function(input, output) {
getData <- reactive({
inFile <- input$file_input
if (is.null(inFile)) {
return(NULL)
} else {
html_session(inFile$datapath)
inputdata <- read_html(inFile)
}
But then I get the following error:
Warning: Error in curl::curl_fetch_memory: Port number ended with '\
Any idea how can I solve this problem?