YAX
Yet Another XML parser is a powerful event-based memory-efficient Python module. It analyses the XML stream node by node and builds subtrees only if it is really needed.
In case of record-oriented XML input (when some subtree structure is repeated many times), it processes the file in a sequential manner similar to that of SAX. However, conditions can be defined which trigger a DOM like processing where subtrees are created.
This method is also efficient on very large data (which do not fit into the memory) both in terms of storage and computational time complexity.
Dependencies
YAX uses Python 3.x and above. It doesn’t depend on any third party module. However, if you have lxml installed you can use it as back-end. (See the documentation about performance.)
Installation
Download as a zip archive, uncompress and use it.
pip3 install yax
(Soon…) Downolad the deb package and install it.
Usage
A simple example which prints all the elements with tagname “a” and containing “href” attribute:
import yax
yr = yax.YAXReader(open("file.xml"))
yr.find("a", {"href": True}).calls(
lambda e, i: print(yax.element_to_string(e, with_tail=False)) # with_tail only whith lxml!
)
yr.start()
A bit more complex example which filters a gpx record. It prints the elevation values of the trackpoints in a specified area:
import yax
yr = yax.YAXReader(open("route.gpx"))
yr.find("trkpt", {"lat": lambda v: 47 < float(v) < 48,
"lon": lambda v: 16 < float(v) < 17},
keep_children="ele"
).calls(lambda e, i: print(e.find("ele").text))
yr.start()
This example shows that it would be erease all unneccessary children from the subtree to save memory but in this case we need the child called “ele”. For more example or the complete reference see the documentation.
See also
Issue tracker (feel free to use it!)
Metadata
Release files for YAX 1.2.0
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 |
|---|---|---|---|---|
| YAX-1.2.0.tar.gz | 7.2 kB | Without provenance | Details for YAX-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| YAX-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for YAX-1.2.0-py3-none-any.whl |
Total release size: 39.6 kB
Release files / YAX-1.2.0.tar.gz
| Download URL | YAX-1.2.0.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
76ee620d1b3a0a898e66c8b7e432a14d61db853b2640aa5717a38a50b2305db4
|
|
BLAKE2b-256 checksum How to use checksums |
e2e436d56a0d10ff6ddc0e1d8bd95e4406be65ff6687bcb98ac35fd7a23e885a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / YAX-1.2.0-py3-none-any.whl
| Download URL | YAX-1.2.0-py3-none-any.whl |
|---|---|
| Size | 32.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ad4c8a706585dd7bdae3dfb0d451268ffd0e3b95b7035caa181c6fcd314ebcec
|
|
BLAKE2b-256 checksum How to use checksums |
61da709a36411981d0d5cade5671fb5e7dae6f4df001fbb9e7a98c3c9ea32393
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for YAX 1.2.0
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.