CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-xml2json

Converts XML to JSON and vice-versa using node-expat parser

Overall
score

93%

Overview
Eval results
Files

task.mdevals/scenario-9/

Catalog XML Publisher

Generate XML for catalog-style data from either JSON strings or plain objects while respecting attribute mapping and text nodes.

Capabilities

Converts JSON string input

  • Given a JSON string with a catalog root containing item entries where each item includes primitive fields for attributes (e.g., id, price) and a $t field for the item text, return XML with an <catalog> root and <item> children whose primitive fields become attributes and $t values become element text. @test

Accepts object input and preserves nested text

  • Given a plain object input for an order root that includes nested elements using $t for text (e.g., customer: { $t: "Jane" }) and additional primitive properties for attributes, produce XML where $t values become element text and primitive properties become attributes on the same element. @test

Escapes unsafe characters

  • When sanitization is requested, the produced XML escapes special characters (such as <, >, &, ', ") in both attribute values and text nodes while keeping the structure unchanged. @test

Skips null entries

  • When null suppression is enabled, null-valued fields do not emit attributes or child elements in the XML output while other fields remain intact. @test

Implementation

@generates

API

export interface CatalogXmlOptions {
  sanitize?: boolean;
  ignoreNull?: boolean;
}

export function buildCatalogXml(input: string | object, options?: CatalogXmlOptions): string;

Dependencies { .dependencies }

xml2json { .dependency }

Handles XML generation from JSON structures with attribute and text node support.

Install with Tessl CLI

npx tessl i tessl/npm-xml2json

tile.json