I have a big XML file which I need to parse with xmlEventParse in R. Unfortunately on-line examples are more complex than I need, and I just want to flag a matching node tag
For others who may try to lear from M.Morgan - here is the complete code
fileName = system.file("exampleData", "mtcars.xml", package = "XML")
ourBranches <- function() {
store <- new.env()
record <- function(x, ...) {
key <- xmlAttrs(x)[["id"]]
value <- xmlValue(x)
store[[key]] <- value
}
getStore <- function() as.list(store)
list(record=record, getStore=getStore)
}
branches <- ourBranches()
xmlEventParse(fileName, list(), branches=branches)
head(branches$getStore(), 2)