https://github.com/cran/XML
Raw File
Tip revision: 7b2de7dca3f93b74a02475c74743e76be5449f8d authored by Duncan Temple Lang on 26 March 2007, 00:00:00 UTC
version 1.6-2
Tip revision: 7b2de7d
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