Overview
XMLStarlet is a set of command line utilities (tools) which can be used to transform,
query, validate, and edit XML documents and files using a simple set of shell commands,
in a similar way to how it is done for plain text files using UNIX grep,
sed, awk, diff, patch,
join, etc.
These utilities can be used by those who deal with many XML documents on a UNIX shell command prompt, as well as for automated XML processing with shell scripts.
Features
The toolkit's feature set includes options to:
- Check or validate XML files (well-formedness check, DTD, XSD, RelaxNG)
- Calculate values of XPath expressions on XML files (such as running sums, etc.)
- Search XML files for matches to given XPath expressions
- Apply XSLT stylesheets to XML documents (including EXSLT support, and passing parameters to stylesheets)
- Query XML documents (e.g. query for the value of some elements or attributes, sorting, etc.)
- Modify or edit XML documents (e.g. delete some elements)
- Format or "beautify" XML documents (such as changing indentation)
- Fetch XML documents using
http://orftp://URLs - Browse the tree structure of XML documents (similar to the
lscommand for directories) - Include one XML document into another using XInclude
- XML c14n canonicalization
- Escape/unescape special XML characters in input text
- Print a directory as an XML document
- Convert XML into PYX format (based on ESIS — ISO 8879), and vice versa
Implementation
The XMLStarlet command line utility is written in C and uses libxml2 and libxslt. Its extensive set of options was only possible because of the rich feature set of libxml2 and libxslt — many thanks to the developers of those libraries for their great work.
XMLStarlet is a single command. Depending on how it was packaged it is invoked as
either xml (the upstream default) or xmlstarlet (used by many
distributions to avoid clashing with other tools) — run it with --help,
or with no arguments, to see the list of available commands.
Standalone builds, such as the Windows release binaries, are linked statically against libxml2 and libxslt, so that one executable is all you need. Packages installed from a distribution instead link dynamically against the system libxml2 and libxslt libraries.
XMLStarlet is open source free software under the MIT license, which allows free use and distribution for both commercial and non-commercial projects.
We welcome feedback on the project. Comments, suggestions, feature requests, and bug reports can be filed on the GitHub issue tracker.