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

Uploaded Python 3

File details

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

File metadata

  • Download URL: xmlightning-0.1.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 1c7002a561b1ce21210340675694bbb26f75d10117884930ed24881ea6f13ca2
MD5 f4ed0c279255912751d766bc121eb3c2
BLAKE2b-256 5cb71fc66963d9827690e293120c5366df67c151859c5cb9010f2c91d139ff1a

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