HXREMOVE(1)

πŸ’– HXREMOVE(1) πŸ’–

okay bestie, welcome to the HTML-XML-utils corner of the group chat β€” this one's hxremove from the HTML-XML-utils fam, and she is so useful. let's get into it 🌸


✨ NAME ✨

hxremove β€” remove elements from an XML file by means of a CSS selector πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

hxremove [ -i ] [ -l language ] selectors

πŸ’… DESCRIPTION πŸ’…

okay so. hxremove reads a well-formed XML document from standard input and writes it to standard output without any elements that match one of the CSS selectors that are given as argument. no cap, that's the whole vibe. for example:

hxremove ol li:first-child

this removes the first li (list item in XHTML) from every ol (ordered list). iconic behavior honestly. ✨

if there are multiple selectors, they must be separated by commas. like, mandatory bestie. for example:

hxremove p + ul, blockquote ol

this removes all ul elements that follow a p element and also all ol elements that are descendants of a blockquote element. two for one, we love to see it 🫢

hxremove assumes that class selectors (".foo") refer to an attribute called "class". and assumes that ID selectors ("#foo") refer to an attribute called "id". that's just the deal, iykyk πŸ’œ

to handle HTML files, make them well-formed XML first, e.g., with hxnormalize -x. it's giving "prep your data first, queen" 🧚

compare with hxselect, which removes everything but the selected elements. literally the opposite energy. 🌈


⭐ OPTIONS ⭐

the following options are supported:

  • -i β€” match case-insensitively. useful for HTML and some other SGML-based languages. (case who? don't know her πŸ’…)
  • -l language β€” sets the default language, in case the root element doesn't have an xml:lang attribute (default: none). example: -l en πŸ“

πŸ‘‘ OPERANDS πŸ‘‘

the following operand is supported:

  • selectors β€” one or more comma-separated selectors. most selectors from CSS level 3 are supported. so like, go off. πŸ’–

πŸ”₯ SEE ALSO πŸ”₯

asc2xml(1), xml2asc(1), hxnormalize(1), hxselect(1), UTF-8 (RFC 2279)


and that's the tea β˜• version 7.x, dated 10 Jul 2011 β€” go forth and delete some elements, bestie, you're the main character of this pipeline πŸŒΈπŸ’…βœ¨