Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse XML using shellscript? [duplicate]

Tags:

linux

bash

shell

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

like image 747
Spredzy Avatar asked Jan 13 '11 12:01

Spredzy


People also ask

How do I read an XML file in Linux?

xml file you want to view. If you're using Gnome, you can open GNOME Files and double-click the folder where the file is stored. If you're using KDE, the built-in file manager is Dolphin. Right-click the file and select Open With Other Application.

Can XML be parsed?

Every XML application has to parse an XML document before it can access the information in the document and perform further processing. Therefore, XML parsing is a critical component in XML applications.


1 Answers

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

like image 56
Joel Avatar answered Sep 20 '22 19:09

Joel