tessl install tessl/pypi-dicttoxml@1.7.0Converts a Python dictionary or other native data type into a valid XML string.
Agent Success
Agent success rate when using this tile
86%
Improvement
Agent success rate improvement when using this tile compared to baseline
0.99x
Baseline
Agent success rate without this tile
87%
A utility that converts structured Python data into XML while allowing callers to toggle automatic type annotations and per-element unique identifiers.
include_types=False and include_ids=False, converting { "title": "Guide", "pages": 2 } using root_name="book" produces XML bytes whose elements carry no type attributes while preserving both fields under the <book> root. @testinclude_types=False and include_ids=True, converting [ {"name": "Ana"}, {"name": "Bo"} ] under root_name="users" returns XML bytes where each generated element (root, item wrappers, and field tags) includes an id attribute and all id values are unique across the document. @testinclude_types=True and include_ids=True, converting { "tasks": [ { "id": 101, "status": "open" } ] } under root_name="project" includes type attributes on every element and unique id attributes while preserving the list nesting. @test@generates
from typing import Any, Iterable, Mapping, Union
def build_xml_payload(
data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]],
include_types: bool = True,
include_ids: bool = False,
root_name: str = "records",
) -> bytes:
"""Convert mappings or iterables of mappings to XML bytes, honoring toggles for type annotations and per-element ids."""Transforms Python data structures into XML with configurable type metadata and id attributes.