https://github.com/cran/XML
Raw File
Tip revision: 17ba60d446f6da77b1143f704f7e0af6839b1d9b authored by CRAN Team on 16 March 2021, 12:52:45 UTC
version 3.99-0.6
Tip revision: 17ba60d
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