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%
Convert inbound records into XML while keeping element names valid and text content safely escaped.
{"summary": "Use < & > symbols"} produces XML with an XML declaration (unless the caller disables it), a root element named after the provided root (default payload), and a <summary> element whose text reads Use < & > symbols. @testname attribute. For example, {"123 status": "ok", "product name": "Road Bike"} yields elements that preserve those keys while keeping tag names XML-safe inside the root wrapper. @test{"order": {"line items": [{"sku": "AB&C", "detail": "Steel <frame>"}], "notes": "Rush"}}, the output contains nested elements for the list and child dictionaries, with text values escaped (e.g., Steel <frame>) and without invalid tag names (e.g., line items not appearing verbatim as a tag). @test@generates
from typing import Any, Mapping
def serialize_payload(payload: Mapping[str, Any], *, root_name: str = "payload", include_declaration: bool = True) -> bytes:
"""Convert the payload into XML bytes with valid element names and escaped text; root tag defaults to 'payload'."""Converts Python data structures into XML with safe tag naming and escaped values.