Skip to main content

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xmlightning-0.1.6-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file xmlightning-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: xmlightning-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 3.9 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

Hashes for xmlightning-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3f9d1f9c8e2039d55e2a207a6be3762eb4292e5a54b26587f6db5bc599e77a45
MD5 262ee9feb490c8e3397618572dff4300
BLAKE2b-256 2e8db8b0d5d2008b316f2ff766a7344792c950d5178c6476cc878a4eda2bde56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page