Name | xmlpydict JSON |
Version |
0.0.9
JSON |
| download |
home_page | |
Summary | xml to dictionary tool for python |
upload_time | 2023-10-22 05:46:21 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | |
keywords |
xml
dictionary
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# xmlpydict 📑
[![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)
[![PyPI versions](https://img.shields.io/badge/python-3.7%2B-blue)](https://github.com/MatthewAndreTaylor/xml-to-pydict)
[![PyPI](https://img.shields.io/pypi/v/xmlpydict.svg)](https://pypi.org/project/xmlpydict/)
## Requirements
- `python 3.7+`
## Installation
To install xmlpydict, using pip:
```bash
pip install xmlpydict
```
## Quickstart
```py
>>> from xmlpydict import parse
>>> parse("<package><xmlpydict language='python'/></package>")
{'package': {'xmlpydict': {'@language': 'python'}}}
>>> parse("<person name='Matthew'>Hello!</person>")
{'person': {'@name': 'Matthew', '#text': 'Hello!'}}
```
## Goals
Create 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.
## Features
xmlpydict allows for multiple root elements.
The root object is treated as the Python object.
### xmlpydict supports the following
[CDataSection](https://www.w3.org/TR/xml/#sec-cdata-sect): CDATA Sections are stored as {'#text': CData}.
[Comments](https://www.w3.org/TR/xml/#sec-comments): Comments are tokenized for corectness, but have no effect in what is returned.
[Element Tags](https://www.w3.org/TR/xml/#sec-starttags): Allows for duplicate attributes, however only the latest defined will be taken.
[Characters](https://www.w3.org/TR/xml/#charsets): Similar to CDATA text is stored as {'#text': Char} , however this text is stripped.
### dict.get(key[, default]) will not cause exceptions
```py
# Empty tags are containers
>>> from xmlpydict import parse
>>> parse("<a></a>")
{'a': {}}
>>> parse("<a/>")
{'a': {}}
>>> parse("<a/>").get('href')
None
>>> parse("")
{}
```
### Attribute prefixing
```py
# Change prefix from default "@" with keyword argument attr_prefix
>>> from xmlpydict import parse
>>> parse('<p width="10" height="5"></p>', attr_prefix="$")
{"p": {"$width": "10", "$height": "5"}}
```
### Exceptions
```py
# Grammar and structure of the xml_content is checked while parsing
>>> from xmlpydict import parse
>>> parse("<a></ a>")
Exception: not well formed (violation at pos=5)
```
### Unsupported
Prolog / Enforcing Document Type Definition and Element Type Declarations
Entity Referencing
Namespaces
Raw data
{
"_id": null,
"home_page": "",
"name": "xmlpydict",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "xml,dictionary",
"author": "",
"author_email": "Matthew Taylor <matthew.taylor.andre@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/8b/14/1561edaa5cdb0cda9bab749dd8cdbffc8428800ed13fbde03ae2082eca89/xmlpydict-0.0.9.tar.gz",
"platform": null,
"description": "# xmlpydict \ud83d\udcd1\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>>> from xmlpydict import parse\n>>> parse(\"<package><xmlpydict language='python'/></package>\")\n{'package': {'xmlpydict': {'@language': 'python'}}}\n>>> parse(\"<person name='Matthew'>Hello!</person>\")\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>>> from xmlpydict import parse\n>>> parse(\"<a></a>\")\n{'a': {}}\n>>> parse(\"<a/>\")\n{'a': {}}\n>>> parse(\"<a/>\").get('href')\nNone\n>>> parse(\"\")\n{}\n```\n\n### Attribute prefixing\n\n```py\n# Change prefix from default \"@\" with keyword argument attr_prefix\n>>> from xmlpydict import parse\n>>> parse('<p width=\"10\" height=\"5\"></p>', 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>>> from xmlpydict import parse\n>>> parse(\"<a></ a>\")\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",
"bugtrack_url": null,
"license": "",
"summary": "xml to dictionary tool for python",
"version": "0.0.9",
"project_urls": {
"Homepage": "https://github.com/MatthewAndreTaylor/xml-to-pydict"
},
"split_keywords": [
"xml",
"dictionary"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2ddbeaf91be429d1a9ab576e7c89f5297c139dca8d8281fae49fd580d8c98030",
"md5": "54da2fd4e786d476cc8bad6bceda41aa",
"sha256": "8966d4f10c8ad974b0987ba0e75d4f6f93d18aad0bf7dbcf3546ce07cb7614e3"
},
"downloads": -1,
"filename": "xmlpydict-0.0.9-cp310-cp310-manylinux_2_34_x86_64.whl",
"has_sig": false,
"md5_digest": "54da2fd4e786d476cc8bad6bceda41aa",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.7",
"size": 149820,
"upload_time": "2023-10-22T05:46:19",
"upload_time_iso_8601": "2023-10-22T05:46:19.488655Z",
"url": "https://files.pythonhosted.org/packages/2d/db/eaf91be429d1a9ab576e7c89f5297c139dca8d8281fae49fd580d8c98030/xmlpydict-0.0.9-cp310-cp310-manylinux_2_34_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8b141561edaa5cdb0cda9bab749dd8cdbffc8428800ed13fbde03ae2082eca89",
"md5": "fa16fcd3059b03ca7f0b63ec1ba5ec68",
"sha256": "39b6a7edd6d8d281c85d0aaf6f7df3d1206d5116566218212d8baf9eb1c28dd1"
},
"downloads": -1,
"filename": "xmlpydict-0.0.9.tar.gz",
"has_sig": false,
"md5_digest": "fa16fcd3059b03ca7f0b63ec1ba5ec68",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 9868,
"upload_time": "2023-10-22T05:46:21",
"upload_time_iso_8601": "2023-10-22T05:46:21.169751Z",
"url": "https://files.pythonhosted.org/packages/8b/14/1561edaa5cdb0cda9bab749dd8cdbffc8428800ed13fbde03ae2082eca89/xmlpydict-0.0.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-22 05:46:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MatthewAndreTaylor",
"github_project": "xml-to-pydict",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "xmlpydict"
}