Converts a Python dictionary or other native data type into a valid XML string.
86
Create an XML document from order records, ensuring the payload is wrapped in an outer element that can use either a default tag or a caller-provided name. Sample input used across tests:
[
{"order_id": 101, "customer": "Ada", "items": ["pen", "paper"]},
{"order_id": 102, "customer": "Lin", "items": ["stapler"]}
]@generates
from typing import Iterable, Mapping, Any, Union
def export_orders(records: Iterable[Mapping[str, Any]], root_tag: str | None = None, as_bytes: bool = True) -> Union[bytes, str]:
"""Convert order records into an XML document with an outer wrapper element."""Converts Python objects into XML documents with configurable wrapping.
Install with Tessl CLI
npx tessl i tessl/pypi-dicttoxmldocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10