XML-CUT(1)

NAME
xml-cut - print selected parts of an XML file as an XML file.

SYNOPSIS

xml-cut OPTION... [ [FILE] [:XPATH]... ]

DESCRIPTION

xml-cut views each leaf node as a virtual line of text beginning with a sequence of tags representing its path from the root to the leaf, and followed by said leaf node's string value. The various options split this line into pieces (characters, fields or tags) and xml-cut keeps only a selection of these pieces, which are reassembled as a leaf node and included in the output. More precisely:

The -c option numbers the characters of a text node's string value, and selects a range of these characters for output. The output XML file contains the same tags and the same tree structure as before, but the text nodes only contain the selections.

The -f option splits a text node into fields separated by whitespace and outputs only the selected fields but all the whitespace. The output XML fie contains the same tags and the same tree structure and the same whitespace as before, but otherwise the text nodes only contain the selections.

For each path leading to a text node, the -t option numbers the tags contained in the path, treating the text node itself as the "last tag". The output XML file contains only a selection of tags and text nodes.

In each case, a range of (characters, fields or tags) is one of

N   N'th character, field or tag, counted from 1

N-  from N'th character, field or tag, to end of node

N-M from N'th to M'th (included) character, field or tag

-M  from first to M'th (included) character, field or tag

OPTIONS

-c  select a range of characters in each text node.

-f  select a range of fields separated by whitespace, in each text node.

-t  select a range of tags and text nodes (treated as tags).

EXIT STATUS
xml-cut returns 0 on success, or 1 otherwise.

EXAMPLE

Remove the second level tags from a document:
    xml-cut -t 1,3- book.xml

AUTHORS

Laird A. Breyer (laird@lbreyer.com) is the original author of this software. The source code (GPLv3 or later) for the latest version is available at the following locations:

http://www.lbreyer.com/gpl.html
http://xml-coreutils.sourceforge.net

SEE ALSO

xml-coreutils(7)