{"id":23507,"library":"data-to-xml","title":"data-to-xml","description":"A simple Python library for converting dictionaries to XML strings. Current version 1.0.9, updated periodically on PyPI.","status":"active","version":"1.0.9","language":"python","source_language":"en","source_url":"https://github.com/anogowski/data-to-xml","tags":["xml","dict","converter","serialization"],"install":[{"cmd":"pip install data-to-xml","lang":"bash","label":"Default install"}],"dependencies":[{"reason":"Used under the hood for XML generation; error if missing.","package":"lxml","optional":false}],"imports":[{"note":"","wrong":"","symbol":"dicttoxml","correct":"from dicttoxml import dicttoxml"}],"quickstart":{"code":"from dicttoxml import dicttoxml\n\nmy_dict = {\n    'name': 'Alice',\n    'age': 30,\n    'items': ['book', 'pen']\n}\n\nxml_str = dicttoxml(my_dict, custom_root='person', attr_type=False)\nprint(xml_str.decode() if isinstance(xml_str, bytes) else xml_str)","lang":"python","description":"Convert a dict to XML with optional root element and type attributes disabled."},"warnings":[{"fix":"Use .decode('utf-8') on the result or wrap with str().","message":"The function returns bytes (not str) by default in Python 3. You must decode if you expect a string.","severity":"gotcha","affected_versions":"all"},{"fix":"Explicitly set attr_type=False when calling dicttoxml().","message":"The 'attr_type' parameter defaults to True, which adds 'type' attributes (e.g., type=\"str\") to each element. This often breaks XML schemas or downstream parsers.","severity":"gotcha","affected_versions":"<2.0.0"},{"fix":"Use custom_root='your_name' instead of root='your_name'.","message":"The 'root' parameter (to set root element name) has been deprecated in favor of 'custom_root'.","severity":"deprecated","affected_versions":">=1.0.9"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from dicttoxml import dicttoxml' or 'import dicttoxml.dicttoxml'.","cause":"Wrong import path; package 'data-to-xml' exposes 'dicttoxml' from its submodule, but the correct import is 'from dicttoxml import dicttoxml'.","error":"ImportError: cannot import name 'dicttoxml' from 'dicttoxml'"},{"fix":"Call .decode('utf-8') on the result or encode your other strings.","cause":"The dicttoxml() result is bytes; concatenating with str without decode.","error":"TypeError: a bytes-like object is required, not 'str'"},{"fix":"Ensure custom_root is a valid XML tag name (no spaces, starts with letter/underscore).","cause":"The root element name contains spaces or special characters not allowed in XML.","error":"ValueError: Invalid root element name"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}