https://github.com/cran/XML
Tip revision: 89e6494d4b3572d033b44942a0b324c221773f47 authored by CRAN Team on 28 October 2022, 09:15:39 UTC
version 3.99-0.12
version 3.99-0.12
Tip revision: 89e6494
connections.R
library(XML)
fileName = system.file("exampleData", "job.xml", package = "XML")
# xmlEventParse(file(fileName, "r"))
xmlConnection =
function(con) {
if(is.character(con))
con = file(con, "r")
if(isOpen(con, "r"))
open(con, "r")
function(len) {
if(len < 0) {
cat("closing connection in xmlConnection\n")
close(con)
return(character(0))
}
cat("getting line from connection\n")
x = character(0)
tmp = ""
while(length(tmp) > 0 && nchar(tmp) == 0) {
tmp = readLines(con, 1)
if(length(tmp) == 0)
break
if(nchar(tmp) == 0)
x = append(x, "\n")
else
x = tmp
}
if(length(tmp) == 0)
return(tmp)
x = paste(x, collapse="")
print(x)
x
}
}
v = xmlEventParse(xmlConnection(fileName))