benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf d62d7b22-535a-5485-b154-1ac4a6f0247f

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import xmltodict
import json

def task_func(s, file_path):
    """
    Converts an XML string into a dictionary representation and saves it as a JSON file.
    This is useful for easily accessing and persisting data stored in XML format.

    Parameters:
    s (str): The XML string to be converted.
    file_path (str): The path where the JSON file will be saved.

    Returns:
    dict: A dictionary representation of the XML string.

    Requirements:
    - xmltodict
    - json

    Examples:
    >>> result = task_func('<person><name>John</name><age>30</age></person>', "temp.json")
    >>> result['person']['name'] + ', ' + result['person']['age']
    'John, 30'
    >>> result = task_func('<school><class><student>Emma</student></class></school>', "temp.json")
    >>> result['school']['class']['student']
    'Emma'
    """

instruct prompt

Converts an XML string into a dictionary representation and saves it as a JSON file. This is useful for easily accessing and persisting data stored in XML format.
The function should output with:
    dict: A dictionary representation of the XML string.
You should write self-contained code starting with:

Code

import xmltodict
import json
def task_func(s, file_path):

code prompt

Code

import xmltodict
import json
def task_func(s, file_path):

entry point

task_func

libs

  • xmltodict
  • json

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import