Skip to main content

Module xml_utils

Module xml_utils 

Source
Expand description

XML building primitives: tag, escape_xml, and extract_xml_tag_value. Low-level XML building primitives used throughout the crate.

These utilities are deliberately simple and allocation-efficient: they work on &str slices and return owned Strings, with no external XML library dependency.

Enums§

TagContent
Content variants for the tag builder function.

Functions§

clear_xml_string
Clean an XML string by removing namespace artifacts, collapsing inter-tag whitespace, and optionally stripping the <?xml … ?> declaration.
escape_xml
Escape special XML characters in text content and attribute values, replacing &, <, >, ", and ' with their XML entity equivalents.
extract_xml_tag_value
Extract the text content of the first occurrence of a simple XML tag in a raw XML string.
pretty_print_xml
Pretty-print an XML string by adding indentation.
remove_invalid_xml_chars
Remove characters that are invalid in XML 1.0 documents.
replace_unacceptable_characters
Replace characters that are valid in XML but rejected by SEFAZ.
tag
Build an XML tag with optional attributes and children.
validate_xml
Validate an NF-e XML string by checking for the presence of required tags.