pub fn stream_extract<F>(
xml: &str,
records_element_path: Option<&str>,
on_record: F,
) -> Result<(), FaucetError>source-rest and source-xml only.Expand description
Walk an XML document with quick_xml::Reader::read_event and invoke
on_record once per element whose path matches the dot-separated
records_element_path selector. Records are materialised as JSON values
in the same shape xml_to_json would produce — attributes become @key
entries, repeated children become arrays, and a single #text child is
flattened to a bare string.
When records_element_path is None the entire document is emitted as
a single record (matches the eager xml_to_json behaviour).
The key difference from xml_to_json is that subtree JSON values are
only materialised while inside a matched element — surrounding elements
are observed via the event stream but never accumulated, which bounds
memory to one matched element + the path stack regardless of total
document size. Combined with batched yielding in
crate::stream::XmlStream’s stream_pages, this keeps client-side
memory at O(batch_size * record_size) even for multi-gigabyte
payloads.