CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-dicttoxml

Converts a Python dictionary or other native data type into a valid XML string.

86

0.98x
Overview
Eval results
Files

task.mdevals/scenario-5/

Catalog XML Builder

Produce an XML document from a list of product dictionaries, returning either bytes for transport or text for logging without manual encoding work.

Capabilities

Byte payload for services

  • Given product entries with names and prices, calling the builder with defaults returns UTF-8 XML as bytes, rooted at catalog with one child element per product. @test

Text payload for logs

  • When as_text=True, the same input returns a Python string containing the XML, preserving characters like Cafe Latte without encoding errors. @test

Consistent content across formats

  • The string produced with as_text=True matches the decoded content of the default byte output aside from the return type. @test

Implementation

@generates

API

from typing import List, Dict, Union

def build_catalog_xml(products: List[Dict], *, as_text: bool = False, root: str = "catalog") -> Union[bytes, str]:
    ...

Dependencies { .dependencies }

dicttoxml { .dependency }

Provides XML serialization of Python objects.

Install with Tessl CLI

npx tessl i tessl/pypi-dicttoxml

tile.json