Skip to contents

Streaming tag scanner for the well-formed machine-generated XML rmorie consumes (CKAN, ArcGIS, StatCan, SIU exports). Emits start/text/end events; morie_fetch_xml builds a plain list tree from them.

Usage

morie_xml_sax(txt, on_start = NULL, on_text = NULL, on_end = NULL)

Arguments

txt

XML text (single string).

on_start, on_text, on_end

Optional callbacks: on_start(tag, attrs), on_text(text), on_end(tag).

Value

Invisibly, the number of elements seen.

Examples

starts <- character(0)
morie_xml_sax("<a><b>hi</b></a>",
              on_start = function(tag, attrs) starts <<- c(starts, tag))
starts
#> [1] "a" "b"