xmlEventParse(file, handlers=xmlHandler(), ignoreBlanks, addContext=T, useTagName=F, asText =F, trim=T, useExpat=F, isURL = F)
xmlTreeParse
, if useExpat
is false, thstartElement()
, endElement()
comment()
, externa
file
argument refers to a URL
(accessible via ftp or http) or a regular file on the system.
If asText
is TRUE, this should not be specified.fileName <- system.file("exampleData", "mtcars.xml", package="XML")
# Print the name of each XML tag encountered at the beginning of each
# tag.
# Uses the libxml SAX parser.
xmlEventParse(fileName, list(startElement=function(name, attrs){cat(name,"")}), useTagName=FALSE, addContext = FALSE)
# Parse the text rather than a file or URL by reading the URL's contents
# and making it a single string. Then call xmlEventParse
xmlURL <- "http://www.omegahat.org/Scripts/Data/mtcars.xml"
xmlText <- paste(scan.url(xmlURL, what="",sep="\n"),"\n",collapse="\n")
xmlEventParse(xmlText, asText=TRUE)
Run the code above in your browser using DataLab