extract_toc: Extract the text of the table of contents from SDMX XML

View source: R/extract_toc.R

extract_tocR Documentation

Extract the text of the table of contents from SDMX XML

Description

Extracts the values of a node from the Eurostat XML Table of contents (TOC) file

Usage

extract_toc(ns)

Arguments

ns

an XML node set from the XML TOC file

Details

It is a sub-function to use in the get_eurostat_toc function.

Value

a character vector with all the values of the node set.

Examples


cfg<-get("cfg",envir=restatapi::.restatapi_env) 
rav<-get("rav",envir=restatapi::.restatapi_env)
toc_endpoint<-eval(parse(text=paste0("cfg$TOC_ENDPOINT$'",rav,"'$ESTAT$xml")))

options(timeout=2)
tryCatch(xml_leafs<-xml2::xml_find_all(xml2::read_xml(toc_endpoint),".//nt:leaf"),
         error = function(e) {xml_leafs<-""},
         warning = function(w) {xml_leafs<-""})
if (exists("xml_leafs")){
   if (Sys.info()[['sysname']]=='Windows'){ 
      xml_node<-as.character(xml_leafs[1])
   }else{
      xml_node<-xml_leafs[1]
   }
   restatapi::extract_toc(xml_node)
}
options(timeout=60)


restatapi documentation built on Sept. 19, 2023, 5:08 p.m.