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_elementsfor 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") fromxml. - extract_
all_ elements - Extract the text content of every
<tag>value</tag>inxml. - 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>inxml. - has_
element - Return
trueif the given tag appears anywhere inxml. - xml_
byte_ size - Return the UTF-8 byte length of the XML string.