Spredzy Spredzy - 10 months ago 112
Bash Question

How to parse XML using shellscript?

I would like to know what would be the best way to parse an XML file using shellscript ?

  • Should one do it by hand ?

  • Does third tiers library exist ?

If you already made it if you could let me know how did you manage to do it


You could try xmllint

The xmllint program parses one or more XML files, specified on the command line as xmlfile. It prints various types of output, depending upon the options selected. It is useful for detecting errors both in XML code and in the XML parser itse

It allows you select elements in the XML doc by xpath, using the --pattern option.

On Mac OS X (Yosemite), it is installed by default.
On Ubuntu, if it is not already installed, you can run apt-get install libxml2-utils