The pyedb.xml_parser.xml_utils library#
Summary#
Parse an XML string into a dictionary. |
|
Serialize a dictionary with a single root key into an XML string. |
Description#
Minimal stdlib XML <-> dict conversion helpers.
The dictionary convention mirrors the one used by xmltodict:
attributes are stored with an
@prefix,text of elements that also have attributes/children is stored under
#text,elements with only text are plain strings, empty elements are
None,repeated sibling tags become lists.
Namespace prefixes (for example c:Control) are preserved verbatim.
Module detail#
- xml_utils.dict_to_xml(data: dict, pretty: bool = True) str#
Serialize a dictionary with a single root key into an XML string.
- Parameters:
- Returns:
strXML document, including the XML declaration.
- Raises:
ValueErrorIf the data doesn’t have exactly one root element or contains invalid XML names.
- xml_utils.escape#
- xml_utils.quoteattr#