https://github.com/cran/XML
Raw File
Tip revision: dcf8ba16b3b0cb0e5edcdc3eb143a42a6b6c2b32 authored by Duncan Temple Lang on 11 September 2006, 00:00:00 UTC
version 0.99-92
Tip revision: dcf8ba1
bondYields.R

uri = "http://www.treas.gov/offices/domestic-finance/debt-management/interest-rate/yield.xml"

h = 
function() {

  tables = list()

  tb = function(node) {
      # this will drop any NULL values from empty nodes.
    els = unlist(xmlApply(node, xmlValue))
    vals = as.numeric(els)
    names(vals) = gsub("BC_", "", names(els))
    tables[[length(tables) + 1]] <<- vals
    NULL
  }

  list("G_BC_CAT" = tb, getTables = function() tables)
}

xmlTreeParse(uri, handlers = h())$getTables()
back to top