#html #xml #document

app xpath-cli

Evaluate XPath selectors on XML or HTML documents

2 stable releases

1.2.0 Mar 2, 2025
1.1.0 Feb 6, 2025

#8 in #documents

Download history 74/week @ 2025-01-31 62/week @ 2025-02-07 8/week @ 2025-02-14 141/week @ 2025-02-28 15/week @ 2025-03-07

156 downloads per month

ISC license

8KB
120 lines

xpath-cli

This is a command line tool called xpath which evaluates XPath expressions on XML or HTML documents. It is a small wrapper around the excellent 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 and toolchain to build it.

Once you have, you can install this tool by running cargo install xpath-cli

Alternately, you can clone this repository, cd into it, and run cargo install --path .

License

The code in this repository is offered under the ISC License. See the LICENSE file for details.

Dependencies

~2–2.6MB
~51K SLoC