email me

XML-Coreutils: A Tutorial

by Laird A. Breyer

This tutorial will bring you up to speed on the xml-coreutils(7) command line tools. These are a collection of utilities very similar to the traditional Unix shell core utilities, but intended for reading and writing XML files.

There are many programs and libraries of code available today which can process XML files, but very few of them are targeted directly at users of the Unix shell (system administrators, developers and casual users), and practically none of them interact cleanly with the existing Unix shell tools. The xml-coreutils are intended to fill this gap.

You can learn about the initial design of xml-coreutils(7) here, or you can read the current manual pages. However, the most important thing you should know is this:

The xml-coreutils try to be as close as possible to the traditional Unix tools. Where it makes sense, they have the same names, the same short command line switches, and behave the same way, except that they work on XML files instead of ordinary text.

Let's begin. If you want to type along, you will need to have an installed copy of xml-coreutils version 0.8 or later (this tutorial was written with version 0.8, if you have a later version you might see small differences in output).

Here's how to check if the tools are installed. Open a terminal and type "xml-file" followed by the enter key as follows (do not type the %, it's only a placeholder for your shell prompt):

% xml-file
Usage: xml-file [OPTION]... FILE [FILE]...
Determine type of FILE(s).

      --help     display this help and exit
      --version  display version information and exit

If you see the usage message, then xml-coreutils is already installed and ready to be used. If you see an error message such as "No such file or directory" then you first have to download and install xml-coreutils from its website, or otherwise.