XMLParsing is an easy-to-use Python 3 parser for compiling, transforming, encoding and decoding XML files and text.
XMLParsing installation:
Run this in your command prompt/shell
pip install xmlparsing
XMLParsing convert dictionary:
xmlparsing.dict2xml
INPUT:
import xmlparsing
myDict = {"numbers": [1, 2, 3], "letters": ["a", "b", "c"], "text": "Lorem ipsum dolor sit amet"}
print(xmlparsing.dict2xml(myDict, title="all"))
OUTPUT:
<?xml version="1.0" encoding="UTF-8"?>
<all>
<numbers>
<item i="0">1</item>
<item i="1">2</item>
<item i="2">3</item>
</numbers>
<letters>
<item i="0">a</item>
<item i="1">b</item>
<item i="2">c</item>
</letters>
<text>Lorem ipsum dolor sit amet</text>
</all>
In the above, you can see that the "title" attribute in xmlparsing.dict2xml is what defines the tag that your entire document will be inside.
XMLParsing convert JSON file:
xmlparsing.jsonfil2xml
INPUT:
import xmlparsing
print(xmlparsing.jsonfile2xml('myStorage.json')
The file "myStorage.json":
{
"numbers": [
1,
2,
3
],
"letters": [
"a",
"b",
"c"
],
"text": "Lorem ipsum dolor sit amet"
}
OUTPUT:
<?xml version="1.0" encoding="UTF-8"?>
<myStorage>
<numbers>
<item i="0">1</item>
<item i="1">2</item>
<item i="2">3</item>
</numbers>
<letters>
<item i="0">a</item>
<item i="1">b</item>
<item i="2">c</item>
</letters>
<text>Lorem ipsum dolor sit amet</text>
</myStorage>
XMLParsing format XML:
xmlparsing.formatxml
INPUT:
import xmlparsing
print(xmlparsing.formatxml('<?xml version="1.0" encoding="UTF-8"?> <all> <numbers> <item i="0">1</item> <item i="1">2</item> <item i="2">3</item> </numbers> <letters> <item i="0">a</item> <item i="1">b</item> <item i="2">c</item> </letters> <text>Lorem ipsum dolor sit amet</text> </all>'))
OUTPUT:
<?xml version="1.0" encoding="UTF-8"?>
<all>
<numbers>
<item i="0">1</item>
<item i="1">2</item>
<item i="2">3</item>
</numbers>
<letters>
<item i="0">a</item>
<item i="1">b</item>
<item i="2">c</item>
</letters>
<text>Lorem ipsum dolor sit amet</text>
</all>
The code above cleans up XML.
XMLParsing convert XML to dictionary:
xmlparsing.xml2dict
INPUT:
import xmlparsing
print(xmlparsing.xml2dict('''
<all>
<numbers>
<item i="0">1</item>
<item i="1">2</item>
<item i="2">3</item>
</numbers>
<letters>
<item i="0">a</item>
<item i="1">b</item>
<item i="2">c</item>
</letters>
<text>Lorem ipsum dolor sit amet</text>
</all>
'''))
OUTPUT:
{'all': {'numbers': {'item': [{'@i': '0', '#text': '1'}, {'@i': '1', '#text': '2'}, {'@i': '2', '#text': '3'}]}, 'letters': {'item': [{'@i': '0', '#text': 'a'}, {'@i': '1', '#text': 'b'}, {'@i': '2', '#text': 'c'}]}, 'text': 'Lorem ipsum dolor sit amet'}}
XMLParsing convert XML to JSON:
xmlparsing.xml2json
INPUT:
import xmlparsing
print(xmlparsing.xml2json('''
<all>
<numbers>
<item i="0">1</item>
<item i="1">2</item>
<item i="2">3</item>
</numbers>
<letters>
<item i="0">a</item>
<item i="1">b</item>
<item i="2">c</item>
</letters>
<text>Lorem ipsum dolor sit amet</text>
</all>
'''))
OUTPUT:
{
"all": {
"letters": {
"item": [
{
"#text": "a",
"@i": "0"
},
{
"#text": "b",
"@i": "1"
},
{
"#text": "c",
"@i": "2"
}
]
},
"numbers": {
"item": [
{
"#text": "1",
"@i": "0"
},
{
"#text": "2",
"@i": "1"
},
{
"#text": "3",
"@i": "2"
}
]
},
"text": "Lorem ipsum dolor sit amet"
}
}
THE END!
Enjoy using XMLParsing!
Metadata
Release files for xmlparsing 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xmlparsing-0.0.1.tar.gz | 3.3 kB | Without provenance | Details for xmlparsing-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xmlparsing-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for xmlparsing-0.0.1-py3-none-any.whl |
Total release size: 7.3 kB
Release files / xmlparsing-0.0.1.tar.gz
| Download URL | xmlparsing-0.0.1.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
73b09fa85cc21401c8bbe9fe52e02a368b892a13c028ed4bcb546c6aa07bb6af
|
|
BLAKE2b-256 checksum How to use checksums |
4d9b7df154f1accaf0fbac180c68a924c9caf832635df9ae447527cd08ec0d0d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6
|
Release files / xmlparsing-0.0.1-py3-none-any.whl
| Download URL | xmlparsing-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3d32ccbaa5fcefb23ff1931809c9f084f06fae9e45a8bddc01371ff58a43cff
|
|
BLAKE2b-256 checksum How to use checksums |
bba667ce3ed37e69230ed12a086e5090e57ad9ca460b4bf8f80ad85568947a7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6
|
Security for xmlparsing 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.