json-tools .ru

Python dict to XML

Parses a Python dict and builds an XML tree from it — for example, to hand data to a legacy system that only accepts XML.

Top-level key and attributes

If the dict has a single top-level key, it becomes the root XML tag name. A nested @attributes key becomes the element's attributes, and #text becomes the text inside the tag — the same convention used when converting from JSON.

True/False and lists

True/False are written into XML as the text true/false, and a list under a key becomes several repeated XML elements with the same tag; tag names are cleaned of characters that aren't valid in XML along the way.

Format
Python → XML
Source text Paste text or upload a file
Result Type is not detected yet
Statistics appear after formatting