https://github.com/cran/XML
Raw File
Tip revision: 3c0b64398bf79b865a4134380b14356c1683f77f authored by Duncan Temple Lang on 31 May 2015, 00:00:00 UTC
version 3.98-1.2
Tip revision: 3c0b643
mexico.R
# An example posed by Herve Richard at INRIA.
variable = function(node) {
   # Get the values.
  vals = scan(textConnection(xmlValue(node)))
   # Need the name attribute
  structure(list(vals),
            names = xmlGetAttr(node, "name"))
}

handlers = list(variable = variable)
ans = xmlRoot(xmlTreeParse("mexico.xml", handlers = handlers, asTree = TRUE))
as.data.frame(xmlChildren(ans[["date"]]))
back to top