https://github.com/cran/XML
Raw File
Tip revision: ccb805f005c1c130824a03bd6209c69841d26d79 authored by Duncan Temple Lang on 17 January 2012, 00:00:00 UTC
version 3.9-4
Tip revision: ccb805f
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))






back to top