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.8-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xmlightning-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 3.8 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 098691b7ff611bd4f6500170a2bf442c660178ab70422c57a3f34fd3316fca5d
MD5 7a7c6ca4fa4ebed04604315b513cb388
BLAKE2b-256 ced68818c0ef97aa612d8167b5239ea6a8c3e8f0551ba0c656118b0ab3d64f29

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