XQ(1)
β¨ XQ(1) β like, the manual page for xq bestie β¨
okay so. <rainbow>xq</rainbow> is a command-line XML and HTML beautifier and content extractor. that's the whole vibe. it takes your crusty unformatted markup and makes it β¨prettyβ¨, and it can also reach in and pull out exactly the node or attribute you want. main character tool tbh π
πΈ SYNOPSIS πΈ
xq [options...] [file]
π DESCRIPTION π
It formats the file you hand it and outputs it in colorful mode. the file can come in as an argument, or you can pipe it through stdin. either way, she's serving. π
β¨ OPTIONS β¨
so here's the full menu, no skips, no cuts, all of it:
--version|-vβ prints version information and then dips out. π--help|-hβ prints the synopsis plus the whole list of options and exits. your little cheat sheet fr.--indent intβ uses the number of spaces you give it for indentation. default is2. πͺ--color|-cβ forces colorful output. no take-backs.--no-colorβ turns colorful output off (formatting only, no color). sad beige mode π₯²--tabβ uses tabs instead of spaces for indentation. team tabs rise up π«Ά--xpath|-x stringβ extracts the node(s) from XML using the XPath query you provide.--extract|-e stringβ extracts a single node from XML using the XPath query you provide. just the one. π--query|-q stringβ extracts the node(s) using a CSS selector.--attr|-a stringβ extracts an attribute value instead of node content, for the CSS query you provide.--html|-mβ uses the HTML formatter instead of the XML one. π¦--json|-jβ outputs the result as JSON.--node|-nβ returns the node content instead of text.--in-place|-iβ formats the file in place. it edits the actual file, bestie, so be sure that's what you want π
π EXAMPLES π
format an XML file and highlight the syntax:
$ xq test/data/xml/unformatted.xml
she also accepts input through stdin, because of course:
$ curl -s https://www.w3schools.com/xml/note.xml | xq
HTML content can be formatted and highlighted using the -m flag:
$ xq -m test/data/html/formatted.html
extract the text content of all nodes with city name:
$ cat test/data/xml/unformatted.xml | xq -x //city
extract the XML content of all nodes with city name:
$ cat test/data/xml/unformatted.xml | xq -n -x //city
π SEE ALSO π
https://github.com/sibprogrammer/xqβ official website
okay that's the whole page, you ate it up, go format something gorgeous π§π
this page is from the xq man page, dated 06 Nov 2022 β and it's listed under XQ(1). periodt. β
π¦ where this page comes from
- epel 10: xq 1.4.0-2.el10_3 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT
- epel 9: xq 1.4.0-2.el9 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT
- fedora 43: xq 1.4.0-2.fc43 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT
- fedora 44: xq 1.4.0-2.fc44 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT
- ubuntu stonking: xq 1.4.0-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms