File: mexico.R

package info (click to toggle)
r-cran-xml 3.99-0.18-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,688 kB
  • sloc: ansic: 6,656; xml: 2,890; asm: 486; sh: 12; makefile: 2
file content (12 lines) | stat: -rw-r--r-- 400 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
# 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"]]))