xmltread
xmltramp was originally created by Aaron Swartz for simple-yet-powerful parsing of RSS and other xml files.
It is a small, fast alternative to heavyweight parsers like BeautifulSoup and ElementTree.
It has been mildly rewritten for python 3 compatibility, including bringing the packaging up to date so it can once again be installed via pip. Sadly, python modules can no longer be built from a single source file, but the tweaked original xmltramp lives inside of xmltread.
from xmltread import xmltramp works, so you don't need to replace xmltramp with xmltread in your code.
Installation
via pip:
pip install xmltread
Usage
Everyone's got their data in XML these days. You need to read it. You've looked at the other XML APIs and they all contain miles of crud that's only necessary when parsing the most arcane documents. Wouldn't it be nice to have an easy-to-use API for the normal XML documents you deal with? That's xmltramp:
>>> sample_xml = """<doc version="2.7182818284590451"
xmlns="http://example.org/bar"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:bbc="http://example.org/bbc">
<author><name>John Polk</name> and <name>John Palfrey</name></author>
<dc:creator>John Polk</dc:creator>
<dc:creator>John Palfrey</dc:creator>
<bbc:show bbc:station="4">Buffy</bbc:show>
</doc>"""
>>> import xmltramp
>>> doc = xmltramp.Namespace("http://example.org/bar")
>>> bbc = xmltramp.Namespace("http://example.org/bbc")
>>> dc = xmltramp.Namespace("http://purl.org/dc/elements/1.1/")
>>> d = xmltramp.parse(sample_xml)
>>> d
<doc version="2.7182818284590451">...</doc>
>>> d('version')
'2.7182818284590451'
>>> d(version='2.0')
>>> d('version')
'2.0'
>>> d._dir
[<author>...</author>, <dc:creator>...</dc:creator>, <dc:creator>...</dc:creator>, <bbc:show bbc:station="4">...</bbc:show>]
>>> d._name
('http://example.org/bar', 'doc')
>>> d[0] # First child.
<author>...</author>
>>> d.author # First author.
<author>...</author>
>>> str(d.author)
'John Polk and John Palfrey'
>>> d[dc.creator] # First dc:creator.
<dc:creator>...</dc:creator>
>>> d[dc.creator:] # All creators.
[<dc:creator>...</dc:creator>, <dc:creator>...</dc:creator>]
>>> d[dc.creator] = "Me!!!"
>>> str(d[dc.creator])
'Me!!!'
>>> d[bbc.show](bbc.station)
'4'
>>> d[bbc.show](bbc.station, '5')
>>> d[bbc.show](bbc.station)
'5'
Credits
Based on the original by Aaron Swartz.
Metadata
Release files for xmltread 0.3
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 |
|---|---|---|---|---|
| xmltread-0.3.tar.gz | 45.1 kB | Without provenance | Details for xmltread-0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xmltread-0.3-py3-none-any.whl | Python 3 | none | any | Details for xmltread-0.3-py3-none-any.whl |
Total release size: 76.0 kB
Release files / xmltread-0.3.tar.gz
| Download URL | xmltread-0.3.tar.gz |
|---|---|
| Size | 45.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3355231a6ace6d81edf3185ec04c38031b4178ad0c95187e1c4a2f6412ff15b4
|
|
BLAKE2b-256 checksum How to use checksums |
0f271d69dd8f106b7a6bbb99af8ff8cbfb2f99924111d6b6ccc1f0685f1b869d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / xmltread-0.3-py3-none-any.whl
| Download URL | xmltread-0.3-py3-none-any.whl |
|---|---|
| Size | 31.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66b515d8b78a7445edf871d597266763932e591557d38859512d56b7e9d51e05
|
|
BLAKE2b-256 checksum How to use checksums |
999e964bf19534b9a3eb536efc5b8dd4a1441346165e1dac50f854ce4d2a7fed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for xmltread 0.3
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.