contact
----------------------------

Blog <-

More XML Commandline unix tools

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>
<a><b>B2</b><c>C1<b>B3</b></c></a>

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

Leave a Reply

You must be logged in to post a comment.