Home Page

More XML Commandline unix tools

Tuesday, November 8th, 2005

A little while ago I reported on a little XML toolset called XMLStarlet. XMLStartlet provided a bunch of commandline tools for reading and converting XML files from the commandline. Usefull in scripts. However, it uses a pretty complex interfacing. For instance, you'll have to know XPath to easily select a particular piece of XML to show.

The XMLCliTools toolset is more in the spirit of traditional Unix tools like grep. It can grep, read and format XML files quite easily. Some examples:

Look for node sequence "top->a" (levelwise). Display from level 1.
jensl:~/c/xmlclitools> xmlgrep -f test.xml 1 top.a
<a><b u="kalle">B1</b></a>

Above with formating.
jensl:~/c/xmlclitools> xmlgrep -gf test.xml 0 b:u=kalle|xmlfmt b:u