https://github.com/cran/XML
Raw File
Tip revision: 89e6494d4b3572d033b44942a0b324c221773f47 authored by CRAN Team on 28 October 2022, 09:15:39 UTC
version 3.99-0.12
Tip revision: 89e6494
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