Allows you to create a simple and advanced xml parser
Project description
xmlightning
xmlightning is a simple, Flask-like way of creating XML parsers
Installation
-
To install xmlightning through pip
pip install xmlightning
Getting Started
For a basic hello world, take the following two files
-
hello_world.xml
<root> <foo>Hello World</foo> </root> -
hello_world.py
from xmlightning import Lightning parser = Lightning() @parser.route("./foo") def hello_world(element): print("hello_world") parser.parse("test.xml")
Breakdown
After the Lightning class gets imported in your project, to use it you must instantiate it.
After the Lightning class was instantiated, the example uses the decorator, "route".
Route Decorator
The route decorator takes in one argument, path, which is a string. Path refers to any valid XPATH string.
Note that the route decorator requires the function it is used on to take in one argument: element.
The type of element can be imported through the following
-
Through xml
from xml.etree.ElementTree import Element -
Or through xmlightning
from xmlightning import Element
Next, the hello_world.xml file is parsed. Whenever the parser encounters a path that matches a route, the function of that route is executed.
Finally, the string from the function is printed to the screen
hello_world
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xmlightning-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xmlightning-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7302705c3951e67e609242659f00758e630ea852cdf94839d32cfe754eccf444
|
|
| MD5 |
8c6ca41636726d3e1f302f81a3e013f8
|
|
| BLAKE2b-256 |
e53863df53becbf482593eaeb93fa228544af9ed0519250cc8fbe42e7528a7d0
|