Coder Social home page Coder Social logo

clixmod's Introduction

clixmod

Status: Basic functionality in the process of being implemented. Author has used for real work

Modify XML and HTML documents using XPATHs from the command line. Analogous to s// in the command-line tool sed. A companion utility to clixpath.

Requires Python3 but can co-exist with Python2.

See also and flagrant self-promotion

  • clixpath is a tool by the author to extract information from XML and HTML documents.

The author also maintains a list of potentially interesting tools they have written here.

Motivation

  • Hopefully easier to use than XSLT
  • Delete element from HTML
  • Change element types
  • Remove attributes
  • Empty the contents of elements into their parents

Examples

# Replace all h2 elements with h1 elements
clixmod //h2 '<h1>{content}</h1>'

# Delete h2 elements
clixmod //h2 ''

# Turn all level-2 headers to level-1 headers
# clixmod //h2 children=descendant::* '<h1>{children}</h1>' # Not implemented

# Not implemented
# Show all the class attributes
# clixmod -f //@class  # Not implemented

# Delete all the class attributes
# clixmod //@class '' # Not implemented

Installing

pip install git+https://github.com/talwrii/clixmod#egg=clixmod

Usage

usage: clixmod [-h] [--debug] [--filter]
               XPATH [selection_xpath [selection_xpath ...]] replacement

Modify xml or html documents

positional arguments:
  XPATH            XPATH to modify
  selection_xpath  relative XPATH to select. Use name=XPATH for named groups
  replacement      XML to replace XPATH with. {} for entire match, {1}... for
                   selection XPATHs

optional arguments:
  -h, --help       show this help message and exit
  --debug          Include debug output (to stderr)
  --filter, -f     Show matches rather than output text

Alternatives and prior work

  • This tool is in many ways nothing more than a convenience wrapper around the lxml library (though this tool will be greatly easier to use for its uses cases)
  • XSLT is a w3c language for transforming XML.

clixmod's People

Contributors

talwrii avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.