sibprogrammer/xq
Fork: 20 Star: 660 (更新于 1970-01-01 00:00:00)
license: MIT
Language: Go .
Command-line XML and HTML beautifier and content extractor
最后发布版本: v1.2.3 ( 2023-11-05 23:34:41)
xq
Command-line XML and HTML beautifier and content extractor.
Features
- Syntax highlighting
- Automatic indentation and formatting
- Automatic pagination
- Node content extraction
Usage
Format an XML file and highlight the syntax:
xq test/data/xml/unformatted.xml
xq
also accepts input through stdin
:
curl -s https://www.w3schools.com/xml/note.xml | xq
HTML content can be formatted and highlighted as well (using -m
flag):
xq -m test/data/html/formatted.html
It is possible to extract the content using XPath query language.
-x
parameter accepts XPath expression.
Extract the text content of all nodes with city
name:
cat test/data/xml/unformatted.xml | xq -x //city
Extract the value of attribute named status
and belonging to user
:
cat test/data/xml/unformatted.xml | xq -x /user/@status
See https://en.wikipedia.org/wiki/XPath for details.
It is possible to use CSS selector to extract the content as well:
cat test/data/html/unformatted.html | xq -q "body > p"
Extract an attribute value instead of node content additional option --attr
(-a
) can be used:
cat test/data/html/unformatted.html | xq -q "head > script" -a "src"
Extract part of HTML with tags (not only text content) using CSS selector:
cat test/data/html/unformatted.html | xq -n -q "head"
Installation
The preferable ways to install the utility are described below.
For macOS, via Homebrew:
brew install xq
For macOS, via MacPorts:
sudo port install xq
For Linux using custom installer:
curl -sSL https://bit.ly/install-xq | sudo bash
For Ubuntu 22.10 or higher via package manager:
apt-get install xq
For Fedora via package manager:
dnf install xq
A more detailed list of Linux distros that package the xq
utility can be found here:
https://repology.org/project/xq-sibprogrammer/versions
If you have Go toolchain installed, you can use the following command to install xq
:
go install github.com/sibprogrammer/xq@latest
You can play with the xq
utility using the Dockerized environment:
docker-compose run --rm xq
xq /opt/examples/xml/unformatted.xml
最近版本更新:(数据更新于 1970-01-01 00:00:00)
2023-11-05 23:34:41 v1.2.3
2023-10-08 23:47:51 v1.2.2
2023-07-09 21:39:57 v1.2.1
2023-07-09 20:26:32 v1.2.0
2023-04-24 18:36:08 v1.1.4
2023-01-25 04:29:17 v1.1.3
2023-01-15 21:18:36 v1.1.2
2022-12-20 04:46:05 v1.1.1
2022-11-28 02:45:17 v1.1.0
2022-11-07 02:13:20 v1.0.0
主题(topics):
cli, formatter, golang, html, syntax-highlighting, terminal, xml, xpath
sibprogrammer/xq同语言 Go最近更新仓库
2024-11-24 20:18:09 SagerNet/sing-box
2024-11-23 10:28:20 ollama/ollama
2024-11-23 05:46:00 dolthub/dolt
2024-11-22 20:14:47 daytonaio/daytona
2024-11-22 08:53:37 AlistGo/alist
2024-11-22 02:54:58 projectdiscovery/nuclei