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-8/

CDATA XML Feed Builder

Transform a collection of article-like records into an XML document while preserving raw text content using CDATA sections. Each record becomes a child of the root element, and each key in the record becomes a child element name.

Capabilities

Wraps text in CDATA

  • String fields such as titles and bodies are emitted inside <![CDATA[...]]> so characters like < and & are not escaped. @test

Keeps numeric content plain

  • Non-string fields (for example, view counts) remain plain text nodes without CDATA wrappers. @test

Custom root tag

  • Supplying a root name creates that root element while still wrapping string fields in CDATA. @test

Implementation

@generates

API

from typing import Iterable, Mapping, Union

def build_feed(entries: Iterable[Mapping[str, Union[str, int, float]]], root_name: str = "feed") -> bytes:
    """Convert entries to an XML document with CDATA-wrapped string content."""

Dependencies { .dependencies }

dicttoxml { .dependency }

Serializes Python data structures to XML and can wrap values in CDATA sections.

Install with Tessl CLI

npx tessl i tessl/pypi-dicttoxml

tile.json