XQ(1)

πŸ“¦
version 1.4.0 Β· 3 versions
, in epel 10, epel 9, fedora 43, fedora 44, ubuntu stonking

✨ 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 is 2. πŸͺ„
  • --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 πŸŽ€


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