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 Distribution

xmlightning-0.0.1.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

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

xmlightning-0.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file xmlightning-0.0.1.tar.gz.

File metadata

  • Download URL: xmlightning-0.0.1.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • 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.0.1.tar.gz
Algorithm Hash digest
SHA256 50d6bc7a8712fa55b9e1741e1e0be5c226c4c8cd2a51da2f7be9f5ddc8367d38
MD5 f1da5ba3d333e3a84d89f3be2fec480f
BLAKE2b-256 45d6ad6558b3ad213dd081c27f8864efccf2bc2bd05c4208ceb5e9f908cc96e1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xmlightning-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7e5ad4b4168a3c31cce22d716159c1a21cf3a29365ceb1280078171bf3147c0
MD5 3a80ac395bbcaaa00542bbf08d2fef99
BLAKE2b-256 81e8e0ce964cc01519b6302eac935afcbee8cc46e1f486d6ebddb07c5222a92e

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