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%
Generate an XML feed from product records for partner ingestion.
<inventory> root, emitting each entry as a <product> element with sequential id attributes when ID annotations are enabled. Nested dictionaries become nested tags. @testinclude_types is true, element nodes carry type metadata attributes; when false, no type metadata appears anywhere in the output. @testuse_cdata is true, string values are wrapped in CDATA sections instead of being entity-escaped. @testas_bytes is true, the function returns bytes that include the XML declaration; otherwise it returns a Unicode string without changing the content. @test@generates
from typing import Iterable, Mapping, Any, Union
def build_inventory_xml(
products: Iterable[Mapping[str, Any]],
*,
with_ids: bool = True,
include_types: bool = True,
use_cdata: bool = False,
as_bytes: bool = False
) -> Union[bytes, str]:
"""Convert products into an inventory XML feed."""Converts Python objects to XML with controllable root naming, id metadata, type annotations, CDATA wrapping, and byte/string outputs.