https://github.com/cran/XML
Tip revision: 582963dfbb3c384687517c42396f7e0f4bd75d83 authored by Duncan Temple Lang on 06 October 2003, 00:00:00 UTC
version 0.95-4
version 0.95-4
Tip revision: 582963d
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))