json-tools .ru

XML to Python dict

Parses XML with lxml and outputs the same data as a Python dict — no manual xml.etree tree-walking required.

Attributes and text in the dict

An element's attributes end up in a nested dict under the '@attributes' key, and its inline text goes under '#text' when the element has both attributes and children. Attribute and text values are always strings, even when they look like numbers.

Repeated tags as a list

Several child tags with the same name automatically become a Python list under that key — no need to write code that checks whether there's one element or several.

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