https://github.com/cran/XML
Tip revision: 5fc4518f6b8f0df6de6d4d8bd2ae88656001925a authored by CRAN Team on 17 September 2021, 05:19:17 UTC
version 3.99-0.8
version 3.99-0.8
Tip revision: 5fc4518
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))