Ctrl + k

or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/dicttoxml@1.7.x
tile.json

tessl/pypi-dicttoxml

tessl install tessl/pypi-dicttoxml@1.7.0

Converts 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%

task.mdevals/scenario-7/

Safe XML Payload Serializer

Convert inbound records into XML while keeping element names valid and text content safely escaped.

Capabilities

Escapes text content

  • Serializing {"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 &lt; &amp; &gt; symbols. @test

Normalizes invalid keys

  • Keys containing spaces or starting with digits are serialized under XML-safe tag names: no output tag contains spaces or starts with a digit, and the original key text remains discoverable either through a normalized tag name or a name 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

Handles nested structures safely

  • Nested dictionaries and lists preserve hierarchy while still applying XML-safe naming and escaping. Given {"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 &lt;frame&gt;) and without invalid tag names (e.g., line items not appearing verbatim as a tag). @test

Implementation

@generates

API

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'."""

Dependencies { .dependencies }

dicttoxml { .dependency }

Converts Python data structures into XML with safe tag naming and escaped values.