https://github.com/cran/XML
Raw File
Tip revision: aebe2ac41917112ffea157920ac4663596a1e234 authored by ORPHANED on 10 August 2018, 14:32:08 UTC
version 3.98-1.15
Tip revision: aebe2ac
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