#xpath #html #xml #evaluate #document #expressions #command-line-tool

app xpath-cli

Evaluate XPath selectors on XML or HTML documents

1 stable release

1.1.0 Feb 6, 2025

#818 in Command line utilities

Download history 132/week @ 2025-02-04 6/week @ 2025-02-11

138 downloads per month

ISC license

6KB
89 lines

xpath is a command line utility to evaluate XPath expressions on XML or HTML documents. It is a small wrapper around the libxml2 library.

Example

Use it for HTML

$ curl -L https://en.wikipedia.org/wiki/Special:Random | xpath '//h1/span/text()'
Vampire bat

Or XML

$ curl -L https://osm.org/api/0.6/changeset/157745397 | xpath '//changeset/tag[@k = "comment"]/@v'
This Starbucks was torn down, seemingly to have extra space to put Halloween candy on display.

Installation

This tool is written in Rust, so you'll need to install the Rust compiler to build it.

Once you have, clone this repository, cd into it, and run cargo install --path . to compile and install.

Dependencies

~1.8–2.5MB
~49K SLoC