.de d \" begin display .sp .in +4 .nf .. .de e \" end display .in -4 .fi .sp .. .TH "HXSELECT" "1" "10 Jul 2011" "7.x" "HTML-XML-utils" .SH NAME hxselect \- extract elements or attributes that match a (CSS) selector .SH SYNOPSIS .B hxselect .RB "[\| " \-i " \|]" .RB "[\| " \-c " \|]" .RB "[\| " \-l .IR language " \|]" .RB "[\| " \-s .IR separator " \|]" .I selectors .SH DESCRIPTION .B hxselect reads a well-formed XML document and outputs all elements and attributes that match one of the CSS selectors that are given as an argument. For example .d hxselect ol li:first-child .e selects the first li (list item in XHTML) in an ol (ordered list). .PP If there are multiple selectors, they must be separated by commas. For example, .d hxselect p + ul, blockquote ol .e selects all ul elements that follow a p and all ol elements that are descendants of a blockquote element. .PP The command operates on the standard input. .PP .B hxselect assumes that class selectors (".foo") refer to an attribute called "class" and that ID selectors ("#foo") refer to an attribute called "id". .PP The experimental attribute node selector .RI '::attr( name )' is supported and selects the attribute of that name. .PP Comments and processing instructions are ignored, i.e., they are read but never written. .SH OPTIONS The following options are supported: .TP 10 .B \-i Match case-insensitively. Useful for HTML and some other SGML-based languages. .TP .B \-c Print content only. Without \fB\-c\fR, the start and end tag of the matched element are printed as well; with \fB\-c\fR only the contents of the matched element are printed. If an attribute rather than an element is selected (::attr() selector), only the value of the attribute is printed. .TP .BI \-l " language" Sets the default language, in case the root element doesn't have an xml:lang attribute (default: none). Example: .B \-l en .TP .BI \-s " separator" A string to print after each match (default: empty). Accepts C-like escapes. Example: .B \-s \(aq\\\\n\\\\n\(aq to print an empty line after each match. .SH OPERANDS The following operand is supported: .TP .I selectors One or more comma-separated selectors. Most selectors from CSS level 3 are supported, with the exception of selectors that require interaction (e.g., ':active') or layout (e.g., ':first-line). .SH "SEE ALSO" .BR asc2xml (1), .BR xml2asc (1), .BR hxnormalize (1), .BR hxremove (1), .BR UTF-8 " (RFC 2279)"