Skip to main content

Module xml_scan

Module xml_scan 

Source
Expand description

Lightweight XML element and attribute extraction utilities.

These functions use simple string scanning rather than full XML parsing. They are intentionally limited: they handle the flat, predictable element structures found in ISO 20022 messages but do not handle CDATA, comments, or namespace-qualified attributes.

§Migration to typed validation

New code should prefer the typed validation path (SchemeValidator::validate_typed) which accesses fields directly on deserialized message structs. The xml_scan utilities remain available for cases where raw XML is the only input (e.g. CLI validation without deserialization).

§Limitations

  • Element extraction is first-match only (use extract_all_elements for repeated elements).
  • Namespace prefixes on tags are not handled — match against the local name only.
  • Attribute extraction searches the whole document, not a specific element.

Functions§

extract_all_attributes
Extract all values of a named XML attribute (e.g. Ccy="USD") from xml.
extract_all_elements
Extract the text content of every <tag>value</tag> in xml.
extract_attribute
Extract the value of a named attribute on a specific element tag.
extract_element
Extract the text content of the first <tag>value</tag> in xml.
has_element
Return true if the given tag appears anywhere in xml.
xml_byte_size
Return the UTF-8 byte length of the XML string.