{"id":20822612,"url":"https://github.com/matthewandretaylor/xml-to-pydict","last_synced_at":"2025-07-31T22:34:49.104Z","repository":{"id":175149203,"uuid":"653444901","full_name":"MatthewAndreTaylor/xml-to-pydict","owner":"MatthewAndreTaylor","description":"Parse xml to python dictionaries","archived":false,"fork":false,"pushed_at":"2024-05-02T08:18:05.000Z","size":44,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-08T16:44:46.115Z","etag":null,"topics":["dictionary","parser","python3","xml"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/xmlpydict","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MatthewAndreTaylor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-06-14T04:22:41.000Z","updated_at":"2024-05-02T08:18:09.000Z","dependencies_parsed_at":"2023-11-06T02:26:38.658Z","dependency_job_id":"f219890e-58d6-4b15-8ddc-48da2eb1191b","html_url":"https://github.com/MatthewAndreTaylor/xml-to-pydict","commit_stats":null,"previous_names":["matthewandretaylor/xml-to-pydict"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthewAndreTaylor%2Fxml-to-pydict","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthewAndreTaylor%2Fxml-to-pydict/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthewAndreTaylor%2Fxml-to-pydict/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthewAndreTaylor%2Fxml-to-pydict/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatthewAndreTaylor","download_url":"https://codeload.github.com/MatthewAndreTaylor/xml-to-pydict/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225096618,"owners_count":17420293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dictionary","parser","python3","xml"],"created_at":"2024-11-17T22:15:33.594Z","updated_at":"2024-11-17T22:15:34.155Z","avatar_url":"https://github.com/MatthewAndreTaylor.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# xmlpydict 📑\n\n[![XML Tests](https://github.com/MatthewAndreTaylor/xml-to-pydict/actions/workflows/tests.yml/badge.svg)](https://github.com/MatthewAndreTaylor/xml-to-pydict/actions/workflows/tests.yml)\n[![PyPI versions](https://img.shields.io/badge/python-3.7%2B-blue)](https://github.com/MatthewAndreTaylor/xml-to-pydict)\n[![PyPI](https://img.shields.io/pypi/v/xmlpydict.svg)](https://pypi.org/project/xmlpydict/)\n\n## Requirements\n\n- `python 3.7+`\n\n## Installation\n\nTo install xmlpydict, using pip:\n\n```bash\npip install xmlpydict\n```\n\n## Quickstart\n\n```py\n\u003e\u003e\u003e from xmlpydict import parse\n\u003e\u003e\u003e parse(\"\u003cpackage\u003e\u003cxmlpydict language='python'/\u003e\u003c/package\u003e\")\n{'package': {'xmlpydict': {'@language': 'python'}}}\n\u003e\u003e\u003e parse(\"\u003cperson name='Matthew'\u003eHello!\u003c/person\u003e\")\n{'person': {'@name': 'Matthew', '#text': 'Hello!'}}\n```\n\n## Goals\n\nCreate a consistent parsing strategy between XML and Python dictionaries. xmlpydict takes a more laid-back approach to enforce the syntax of XML. However, still ensures fast speeds by using finite automata.\n\n## Features\n\nxmlpydict allows for multiple root elements.\nThe root object is treated as the Python object.\n\n### xmlpydict supports the following \n\n[CDataSection](https://www.w3.org/TR/xml/#sec-cdata-sect):  CDATA Sections are stored as {'#text': CData}.\n\n[Comments](https://www.w3.org/TR/xml/#sec-comments):  Comments are tokenized for corectness, but have no effect in what is returned.\n\n[Element Tags](https://www.w3.org/TR/xml/#sec-starttags):  Allows for duplicate attributes, however only the latest defined will be taken. \n\n[Characters](https://www.w3.org/TR/xml/#charsets):  Similar to CDATA text is stored as {'#text': Char} , however this text is stripped.\n\n### dict.get(key[, default]) will not cause exceptions\n\n```py\n# Empty tags are containers\n\u003e\u003e\u003e from xmlpydict import parse\n\u003e\u003e\u003e parse(\"\u003ca\u003e\u003c/a\u003e\")\n{'a': {}}\n\u003e\u003e\u003e parse(\"\u003ca/\u003e\")\n{'a': {}}\n\u003e\u003e\u003e parse(\"\u003ca/\u003e\").get('href')\nNone\n\u003e\u003e\u003e parse(\"\")\n{}\n```\n\n### Attribute prefixing\n\n```py\n# Change prefix from default \"@\" with keyword argument attr_prefix\n\u003e\u003e\u003e from xmlpydict import parse\n\u003e\u003e\u003e parse('\u003cp width=\"10\" height=\"5\"\u003e\u003c/p\u003e', attr_prefix=\"$\")\n{\"p\": {\"$width\": \"10\", \"$height\": \"5\"}}\n```\n\n\n### Exceptions\n\n```py\n# Grammar and structure of the xml_content is checked while parsing\n\u003e\u003e\u003e from xmlpydict import parse\n\u003e\u003e\u003e parse(\"\u003ca\u003e\u003c/ a\u003e\")\nException: not well formed (violation at pos=5)\n```\n\n\n### Unsupported\n\nProlog / Enforcing Document Type Definition and Element Type Declarations\n\nEntity Referencing\n\nNamespaces\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewandretaylor%2Fxml-to-pydict","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthewandretaylor%2Fxml-to-pydict","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthewandretaylor%2Fxml-to-pydict/lists"}